MyBB Community Forums

Full Version: How to include jquery in index template?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do we include jquery in index template?

Thanks
The same way as you would in any other template.
Which is what?

Do I need to use "jQuery" instead of "$" ?

Before my actual script I use;
<script src="http://code.jquery.com/jquery-latest.js">jQuery.noConflict();</script>

So my script is like this
<script src="http://code.jquery.com/jquery-latest.js">jQuery.noConflict();</script>
<script>
blah blah blah
</script>

Still a no go Sad

----------------------------------------------------------------------------

Also my headerinclude, includes this at the bottom;

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>
    jQuery.noConflict();
</script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
    jQuery.noConflict();
</script>
<script type="text/javascript">
 jQuery.noConflict();
 </script>

Do I need template conditionals plugin or the php in templates plugin?
Sorry @FooFighter I don't quite get your problem...
Use this instead of the messy one in headerinclude Toungue

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>
    jQuery.noConflict();
</script>
Still nothing, I can get it to work flawlessly in a pagemanger page, with "mybb templates set to no" but in my index template it doesn't take my jquery code.

So do I need template conditionals to run jquery scripts in templates? or even php in templates mod?
(2012-09-09, 09:41 PM)FooFighter Wrote: [ -> ]Still nothing, I can get it to work flawlessly in a pagemanger page, with "mybb templates set to no" but in my index template it doesn't take my jquery code.

So do I need template conditionals to run jquery scripts in templates? or even php in templates mod?

What is the problem mate? It is so simple to include jquery.... IF you mean your other javascripts are not working then please post your Headerinclude template.
Maybe try to put your Jquery code into the tags like Yaldaram showed:
http://yaldaram.com/thread-40.html

<script type="text/javascript">
jQuery.noConflict();
jQuery(function($) {


// Your ! jQuery Code goes on this line



});
</script>

Always use that seems to work well so.
Exactly. Standard jQuery functions come as :

$.(function() {
.
.
});

All you have to do is change the line:
$.(function() {
to
jQuery(function($) {

and add this line before that:
jQuery.noConflict();

rest will remain same.