Search code examples
titaniumtitanium-mobileappceleratorappcelerator-mobile

How to add a listener to the DONE button in document viewer


I have opened a PDF file by using document viewer in titanium.

var viewer = Ti.UI.iOS.createDocumentViewer({ url: "sample.pdf" }); viewer.show();

It will open a viewer with a "DONE" button on top left, when clicks , closes this viewer. May I know to handle that listener?

Thanks, Swathi.


Solution

  • You can't listen directly for the 'click' event on that button. But you could listen for the 'unload' event! It is fired when the document is dismissed (that is to say, after you have clicked on the "DONE" button)

    var viewer = Ti.UI.iOS.createDocumentViewer({
        url: "sample.pdf"
    });
    viewer.addEventListener('unload', function(e) {
        // something to do after the document has been dismissed
    });
    viewer.show();
    

    More info about the 'unload' event here