jQuery Mobile - firing pageshow event only once -


i trying execute snippet of js once, after page has loaded , jqm has taken care of ui modifications (i.e. listviews, buttons, etc.). want execute on page, , not on subsequent pages.

what tried first, pageshow

<script> $('[data-role=page]').live("pageshow", function() {     alert("ready!"); });  </script> 

this has problem function attached page div , gets executed every time subsequent page gets shown. however, want executed once, , page contains js snippet.

is there way listen pageshow event, without attaching function it.

the way able binding , unbinding this:

<script> $('[data-role=page]').bind("pageshow.test", testfun);  function testfun() {     alert("ready!");     $('[data-role=page]').unbind("pageshow.test", testfun); }    </script> 

but there more elegant way so?

jquery has one function bind event handler executed once. check reference.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -