Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS $(document).ready() not working for jquery mobile

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #45003
    amyth91
    Participant

    hi,

    i am setting up a jquery mobile site and using a jquery carousel on one of the pages.

    but document.ready() function does not work at all.

    i tried :

    – $(document).bind(‘pageinit’)

    – $(document).live(“pageinit”, function (event) {}

    but nothing seems to work on the first load, unless i do a refresh. can anyone please suggest an alternative.

    thanks.

    #136765
    JohnMotylJr
    Participant

    Why not start off with an anonymous function?

    function init() { ... Do stuff }

    $(function() {
    init();
    });
    #136772
    CrocoDillon
    Participant

    Can’t tell why without seeing the actual code but I guess you did something like `$(document).ready( init() )` instead of `$(document).ready( init )` (first runs the function, second references to it). You can do it like John said, but if the only thing you do in that anonymous function you might as well just do

    $(init);

    or

    $(function() {
    // … Do stuff
    });

    #136775
    JohnMotylJr
    Participant

    @CrocoDillon, or EVEN:

    (function init() {
    // Do Stuff
    })();

    How long you think we can do this? lol… Anonymous functions are greatness!!!!

    #136776
    CrocoDillon
    Participant

    Haha… that doesn’t make sense! :P

    #136777
    JohnMotylJr
    Participant

    @CrocoDillon, and another

    ;(function init() {
    // ... Do some more stuff
    })();

    Alright, i think i am done now!

    #136685
    amyth91
    Participant

    thanks guys, i tried this stuff, but i still could not get it working, the fix was to remove the ajax page calls.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘CSS’ is closed to new topics and replies.