Phonegap - jquery Mobile : button click event not able catch in android -
i developing sample app using phonegap jquery mobile plugin android. created page, main.html. main.html, able catch event. once button pressed in main page, change contents using( $.mobile.changepage("path")
) function signup.html. have button in signup.html when click button click event not fired. have loaded js file in signup.html well. doing wrong? please guide me.
clarification: should keep 1 html (main.html ) , through have page navigation.?
in case second page javascript placed inside head content
if understood correctly, using ajax load page dom? if true understand problem. see, when ajax used page loading body content loaded dom.
you can fix problem if initialize second html page javascript inside first html file or move script block inside second html body content.
also, have described problem in other article more details , few examples, or can found here.
in case have several buttons same id
this little different problem. see, if have 2 buttons same id, both inside dom structure. if try bind click event on second page button, same event bound button on first page. because have same id jquery bound event first button (with id) found in dom.
to fix problem need use jqm constructor called active page. 1 more warning, next code example work in page events initialized after pageinit event, example pagebeforeshow or pageshow events:
$(document).on('pagebeforeshow', '#yourpageid', function(){ // registering button click $(document).on('click', $.mobile.activepage.find('#mybuttonid'), function(){ // }); });
this line of code:
$.mobile.activepage.find('#mybuttonid')
will button '#mybuttonid' found in current active page, no matter how many other buttons same id exist inside dom.
answer last question
about last questions. doesn't matter template structure use (1 html multiple pages or multiple html's), need worry things mentioned before.
Comments
Post a Comment