Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ratchet push.js with phonegap (cordova)

I use Ratchet. My phonegap app has two pages, containing jquery.js, ratchet.js, and blockui.js (jQuery-based).

index.html:

<script>$.blockUi()</script>
<a href="2.html" data-transition="slide-in">2.html</a>

2.html:

<a href="index.html" data-transition="slide-out">index.html</a>

at first $.blockUi() runs correctly. then I press the link at the first page. After I press the link on the second page, no JavaScript runs. What should I do?

like image 214
Ebrahim Tahernejad Avatar asked Mar 07 '14 17:03

Ebrahim Tahernejad


1 Answers

From the docs on Github:

Script tags containing JavaScript will not be executed on pages that are loaded with push.js. If you would like to attach event handlers to elements on other pages, document-level event delegation is a common solution.

From the docs site

Push.js binds an event to the document that returns a detail object and can be used to fire a callback.

Therefore I believe you would have to use this event listener to get your scripts to run: window.addEventListener('push', myFunction);

like image 200
james Avatar answered Nov 14 '22 11:11

james