1

I am using jQuery Mobile v1.2.0 and i'm attempting to implement a callback function with the jQuery trigger function on a click/vclick on a link.

This is my callback function and the trigger below it.

var callback = function() {
   console.log('in the callback, yo!');
   var mainContainer = $.mobile.activePage.find('.main');
   // do some stuff...  
};

$.mobile.activePage.find('.new_link').trigger('click', [callback]);

What I am finding is that Callback is pulling through as undefined when I do a typeof on it. My understanding is this should be a function, which is what i'm checking for, but for some reason it does not find it.

var page = $.mobile.activePage;

page.on('vclick', '.new_link', function(e, Callback) {
    e.stopPropagation();
    e.preventDefault();

    // comes through as 'undefined'
        console.log(typeof(Callback));

    if (typeof Callback === 'function') {
        Callback();
    }

});

I can see that the code gets as far as checking for the type of Callback, but it does not have a function. I see nothing in the jQuery trigger documentation for a callback such as this, but i'm led to believe it does work.

4

0 回答 0