Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Smarty with Superfish and JQuery

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
glowens
Smarty Rookie


Joined: 05 Apr 2008
Posts: 11

PostPosted: Wed Aug 27, 2008 2:59 pm    Post subject: Smarty with Superfish and JQuery Reply with quote

I am running the Superfish menu and trying to get the following jquery code to work with Smarty. It appears the code is having a problem with the $. Below is the code

Code:
{literal}
<script type="text/javascript">
    $(document).ready(function(){
           $("ul.sf-menu").superfish({
            pathClass:  'current'
        });
    });
 
</script>{/literal}


Any suggestions?
Back to top
View user's profile Send private message
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Wed Aug 27, 2008 3:28 pm    Post subject: Reply with quote

Since you put it in a {literal}{/literal} block it seems to be no Smarty related issue.
_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
glowens
Smarty Rookie


Joined: 05 Apr 2008
Posts: 11

PostPosted: Wed Aug 27, 2008 3:35 pm    Post subject: Reply with quote

I believe the issue is with the $ I change the code to

Code:
    jQuery(document).ready(function(){
           $("ul.sf-menu").superfish({
            pathClass:  'current'
        });
    });


And it at least loads the code but now I get a different error with the $.

Is there a Jquery pluggin for smarty?
Back to top
View user's profile Send private message
glowens
Smarty Rookie


Joined: 05 Apr 2008
Posts: 11

PostPosted: Wed Aug 27, 2008 3:49 pm    Post subject: Reply with quote

More info

I call Superfish using the basic code below but it will not work
$(document).ready(function(){
$("ul.sf-menu").superfish({
pathClass: 'current'
});
});

I changed the code to the following and it appears to call the code.
jQuery(document).ready(function(){
$("ul.sf-menu").superfish({
pathClass: 'current'
});
});

But I get the following error
this.cloneNode is not a function
[Break on this error] return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function()...

I beleive the issue is with the $. I tested this with the following.
jQuery(document).ready(function(){
alert('test')
});
});
and the alert is displayed. If I change the JQuery back to a $ it will not work.

Any ideas or other ways to initiate the Superfish code.[/code]
Back to top
View user's profile Send private message
amirsadig
Smarty Rookie


Joined: 14 May 2004
Posts: 12

PostPosted: Wed Aug 27, 2008 4:24 pm    Post subject: Reply with quote

do you use different javascript like prototyp ..
most of them use $ which get conflict with jquery.

do the following

var $jQ = jQuery;
$jQ(document).ready(function(){
$jQ("ul.sf-menu").superfish({
pathClass: 'current'
});
});

and read the following site:
http://docs.jquery.com/Using_jQuery_with_Other_Libraries
Back to top
View user's profile Send private message
glowens
Smarty Rookie


Joined: 05 Apr 2008
Posts: 11

PostPosted: Wed Aug 27, 2008 4:31 pm    Post subject: Reply with quote

Thanks

I also found the document you reference and made the changes but now I get another error. It works when I do not use smarty. I have identical code in my smarty site and my non-smarty site.

this.cloneNode is not a function
[Break on this error] return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function()...
Back to top
View user's profile Send private message
amirsadig
Smarty Rookie


Joined: 14 May 2004
Posts: 12

PostPosted: Wed Aug 27, 2008 4:40 pm    Post subject: Reply with quote

it is not related with smarty, it is related with javascript.

and it may still the same problem. try to look at the implementation of the Superfish plugin.
most plugin start with:

(function($) {
// plugin code here, use $ as much as you like
})(jQuery);
Back to top
View user's profile Send private message
glowens
Smarty Rookie


Joined: 05 Apr 2008
Posts: 11

PostPosted: Wed Aug 27, 2008 4:43 pm    Post subject: Reply with quote

Okay. The superfish.js uses function($). Do I need to replace the $ with $jQ as well?
Back to top
View user's profile Send private message
glowens
Smarty Rookie


Joined: 05 Apr 2008
Posts: 11

PostPosted: Wed Aug 27, 2008 7:04 pm    Post subject: Reply with quote

Forget my last question. I have been working on this so long I am brain dead and not think properly.

BTW I have narrowed it down to something with prototype.js is interfering with the jquery.min.js.

Any idea?
Back to top
View user's profile Send private message
glowens
Smarty Rookie


Joined: 05 Apr 2008
Posts: 11

PostPosted: Wed Aug 27, 2008 10:14 pm    Post subject: Reply with quote

Figured it out. my jsquery.mim.js was interfering with the effect.js file from scriptulaous. I upgraded to the latest version and the problem is fixed.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP