I need some help:
- I have three separate JQM pages – page1.html, page2.html and page3.html.
- I’m adding my .js files to all pages, so whichever page is loaded first also loads the plugin
- page2.html has a trigger called data-somesome=”true” to fire the plugin on page2
- I have added a listener that waits for the trigger page to be created
Looks like this:
(function($,window){
$.widget("mobile.somesome",$.mobile.widget, {
_create: function() {
var self = this;
console.log("here we go");
...
}
});
// initialize
var trigger = $('div:jqmData(somesome="true")').live( 'pagecreate',function(event){
if ($('html').data('somesome-init', 'Off')) {
$('html').data('somesome-init', 'On')
console.log("trigger fired");
trigger.somesome();
}
});
}) (jQuery,this);
Problem:
If I load page2.html directly, everything works as normal = console logs the trigger has been fired and the plugin runs.
However, if I start on either page1.html or page3.html and then call page2.html hoping the plugin would fire, I only get the console “trigger fired”, so I’m detecting correct, but the plugin itself doesn’t run.
Can anybody give me a hint?
EDIT
Added some examples:
– page2 direct load this directly, and the color changes to red
– via page1 start from here, then go to page2, nothing happens
– via page3 or start from here and go to page2, also nothing happens
$(this) makes it work… like so: