SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Nov 2005
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Anyway of having two $(document).readys in jQuery?

    Hello there.

    I'm working on a site with an integrated CMS that works inside the site itself. I'm trying to be very good and keep things as separate as possible from the site itself. I'm using CodeIgniter as the framework (works great for this actually) and I'm using jQuery for pretty much all of the Javascript work.

    Thing is, I want two JS files - one called site.js and one called manager.js (manager being the CMS bit)... This is so when my designer is working on the site, they can twiddle with the site.js as much as they like, without destorying all the manager goodness...

    But... I have $(document).ready in both JS files and this obviously doesn't work... But is there a way of making it work? It's purely for nice and simple separation... jQuery stuff for the site and jQuery stuff for the manager.

    Any help? Cheers.

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If you read the documentation you can see that it says you can have as many of those as you want. Are you sure they don't work? Also, are you sure the jQuery script is appearing before the others in the HTML?

  3. #3
    SitePoint Evangelist
    Join Date
    Nov 2005
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply. Well, this is it... I thought I could have as many as I wanted, but it just doesn't seem to work for me... I'll do what you say here, see if it works, but yes... At the moment, it just doesn't seem to work.

  4. #4
    SitePoint Evangelist
    Join Date
    Nov 2005
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm... In the source code on the documentation it says:

    $(document).ready(function(){
    $(document).ready(function () {
    $("p").text("The DOM is now loaded and can be manipulated.");
    });
    });
    One ready() is inside the other ready(). In my app, it needed to be one ready() (in one js file) followed by another ready() (in the next js file)... This maybe the problem?

    But, I wonder if there is a way around that?

  5. #5
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I see what you mean. I don't understand what the point of nesting them like that is. I think it's a mistake (the bad indentation and the talk page seem to suggest this). I also don't understand why having more than one, side by side, should not work. I suggest you ask your question in the jQuery mailing list.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •