Monday, 15 September 2014

javascript - Add `destroy` method to Snap.js mobile panel plugin -



javascript - Add `destroy` method to Snap.js mobile panel plugin -

how add together destroy method snap.js mobile panel? if it's matter of removing info / references set, best way of going that?

https://rawgit.com/jakiestfu/snap.js/v2.0.0-rc1/src/snap.js

basically need able shut downwards before reinitializing on jquery mobile page change -- otherwise work on first page:

http://jsfiddle.net/frank_o/l3dkmkrx/1/

the below code clones snap panel, places before current page , initialize on pagecontainershow.

$(document).on("pagecontainershow", function (e, data) { var drawer = $(".snap-drawers").clone(); /* clone */ $(".snap-drawers").remove(); /* remove */ $(data.topage).before(drawer); /* place before page */ var snapper = new snap({ element: $(data.topage)[0] /* initialize */ }); $('.open-panel') .off("click") /* remove previous click listener */ .on("click", function () { /* re-bind click */ snapper.open('left'); }); $('.close') .off("click") /* remove previous click listener */ .on('click', function () { /* re-bind click */ snapper.close(); }); });

demo - code

javascript jquery jquery-mobile

No comments:

Post a Comment