SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Aug 2011
    Location
    Trinidad and Tobago
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Jquery and Jquery mobile

    How to do execute a JavaScript function after your html elements have been loaded onto the page? For example if i want to call a function but only after the html in the page is load how will I call it?

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,151
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Code:
    $(function() {
     // Your code here
    });
    You can get to this from http://docs.jquery.com

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2011
    Location
    Trinidad and Tobago
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok so I have a function called events would I do this $(function() {
    events();
    });

    Lastly if am using jquery mobile I can create several pages within the same document using <div data-role="page" data-add-back-btn="true" id="venues"> how can I call another js functional called test(); within that page?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,712
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by skelleex View Post
    Lastly if am using jquery mobile I can create several pages within the same document using <div data-role="page" data-add-back-btn="true" id="venues"> how can I call another js functional called test(); within that page?
    From the jQuery mobile events page it seems that the pageshow event may be what you're after.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Zealot
    Join Date
    Aug 2011
    Location
    Trinidad and Tobago
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually am using a pageinit handler which seems to be working not sure if thats the way to go though

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,712
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by skelleex View Post
    Actually am using a pageinit handler which seems to be working not sure if thats the way to go though
    Yes, that's good. That's the recommended one to use.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •