SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Jul 2009
    Posts
    356
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery include file?

    Trying to use the jQuery noConflict() function, I got it to work fine when pasting all the code on my actual index.html page, but is there anyway to do some kinds of includes below so it looks a bit cleaner?

    Code:
      
    <script type="text/javascript">
        //no conflict jquery
        jQuery.noConflict();
        //instead of pasting all my code here, can i use some kind of syntax to include my scripts.js file?
    
        })(jQuery);
    </script>

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,198
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Simply create a new *.js file and place all your javascript in it and link to the file like you would with jQuery.

    HTML Code:
    <script type="text/javascript" src="/path/to/js/custom.js"></script>

  3. #3
    SitePoint Addict
    Join Date
    Jul 2009
    Posts
    356
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SgtLegend View Post
    Simply create a new *.js file and place all your javascript in it and link to the file like you would with jQuery.

    HTML Code:
    <script type="text/javascript" src="/path/to/js/custom.js"></script>
    The problem is (from what I understand) is that the noconflict function call needs to reside on the index page itself, and cannot be referenced in the .js file for it to function correctly.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by noslenwerd View Post
    The problem is (from what I understand) is that the noconflict function call needs to reside on the index page itself, and cannot be referenced in the .js file for it to function correctly.
    That's incorrect. The noconflict command can reside in the script file itself too without any difficulty.
    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
  •