Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-15-2010, 08:17 PM   PM User | #1
finstah1
Regular Coder

 
Join Date: May 2004
Location: The First State
Posts: 233
Thanks: 9
Thanked 0 Times in 0 Posts
finstah1 is an unknown quantity at this point
jQuery trouble loading stylesheet

I'm trying to load a css file as needed. I'm looking for the #slider as my trigger. If it exists, then load this style sheet.

I've tried both methods below and neither work. Am I missing something somewhere?

Code:
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>
<script type="text/javascript">
            $(document).ready( function() {
          
               if ( $("#slider").length > 0) {
                $('<link>').appendTo('head').attr({
      rel:  "stylesheet",
      type: "text/css",
      href: "/css/controls10.css"
    });
             
            }
         });
</script>-->

  <script type="text/javascript">
            $(document).ready( function() {
          
               if ( $("#slider")) {
								 $("link[rel=stylesheet]").attr({href : "css/controls10.css"});
             
            }
         });
Also is there a way to cache the plugin call? I read .getScript doesn't cache so I tried .ajax.

Code:
$.ajax({
            type: 'GET',
            url: 'xxx',
            cache: true,
            success: function() {$("#slider").easySlider({
				auto: true, 
				continuous: true,
				numeric: true,
				numericId: 'controls',
				speed: 800,
				pause:	6000

			}); },
            dataType: 'script',
            data: null
         });
I only want to make the function call and not use a url. (Since there is no file needed to run this.)

Any help is appreciated

Last edited by finstah1; 02-15-2010 at 09:14 PM..
finstah1 is offline   Reply With Quote
Old 02-15-2010, 08:40 PM   PM User | #2
finstah1
Regular Coder

 
Join Date: May 2004
Location: The First State
Posts: 233
Thanks: 9
Thanked 0 Times in 0 Posts
finstah1 is an unknown quantity at this point
I figured out the first part.

Code:
 $('head').append('<link rel="stylesheet" href="css/controls10.css" type="text/css" />');
finstah1 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:07 AM.


Advertisement
Log in to turn off these ads.