MyBB Community Forums

Full Version: Need help with jQuery
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
There is some info on this if you search here on mybb but I do not quite understand it what I can gather is you add
<script>
jQuery.noConflict();
</script>
after you intrduced jQuery

Now I have been tryng to get this to work for me
http://tutorialzine.com/2010/03/sponsor-...query-css/
and I have had no luck at all

this is my headderinclued
<link rel="alternate" type="application/rss+xml" title="{$lang->latest_threads} (RSS 2.0)" href="{$mybb->settings['bburl']}/syndication.php" />
<link rel="alternate" type="application/atom+xml" title="{$lang->latest_threads} (Atom 1.0)" href="{$mybb->settings['bburl']}/syndication.php?type=atom1.0" />
<meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/prototype.js?ver=1603"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/general.js?ver=1603"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/popup_menu.js?ver=1600"></script>
<script type="text/javascript" src="htt://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script type="text/javascript" src="htt://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>
<script type="text/javascript" src="myaddons/sponsorpage/jquery-1.6.1.min.js"></script>
<script>
    jQuery.noConflict();
</script>
<script type="text/javascript" src="myaddons/sponsorpage/jquery-ui-1.8.13.custom.min.js"></script>
<script type="text/javascript" src="myaddons/sponsorpage/jquery.flip.min.js"></script>

<script type="text/javascript" src="myaddons/sponsorpage/script.js"></script></script>
{$stylesheets}
<script type="text/javascript">
<!--
	var cookieDomain = "{$mybb->settings['cookiedomain']}";
	var cookiePath = "{$mybb->settings['cookiepath']}";
	var cookiePrefix = "{$mybb->settings['cookieprefix']}";
	var deleteevent_confirm = "{$lang->deleteevent_confirm}";
	var removeattach_confirm = "{$lang->removeattach_confirm}";
	var loading_text = '{$lang->ajax_loading}';
	var saving_changes = '{$lang->saving_changes}';
	var use_xmlhttprequest = "{$mybb->settings['use_xmlhttprequest']}";
	var my_post_key = "{$mybb->post_code}";
	var imagepath = "{$theme['imgdir']}";
// -->
</script>
{$newpmmsg}
and the testpage.php file
<html>
<head>
<title>{$mybb->settings[bbname]} - Test Page</title>
{$headerinclude}
<link rel="stylesheet" type="text/css" href="myaddons/sponsorpage/styles.css" />
</head>
<body>
{$header}
<br/>

<?php

// Each sponsor is an element of the $sponsors array:

$sponsors = array(
	array('facebook','The biggest social network in the world.','http://www.facebook.com/'),
	array('adobe','The leading software developer targeted at web designers and developers.','http://www.adobe.com/'),
	array('microsoft','One of the top software companies of the world.','http://www.microsoft.com/'),
	array('sony','A global multibillion electronics and entertainment company ','http://www.sony.com/'),
	array('dell','One of the biggest computer developers and assemblers.','http://www.dell.com/'),
	array('ebay','The biggest online auction and shopping websites.','http://www.ebay.com/'),
	array('digg','One of the most popular web 2.0 social networks.','http://www.digg.com/'),
	array('google','The company that redefined web search.','http://www.google.com/'),
	array('ea','The biggest computer game manufacturer.','http://www.ea.com/'),
	array('mysql','The most popular open source database engine.','http://www.mysql.com/'),
	array('hp','One of the biggest computer manufacturers.','http://www.hp.com/'),
	array('yahoo','The most popular network of social media portals and services.','http://www.yahoo.com/'),
	array('cisco','The biggest networking and communications technology manufacturer.','http://www.cisco.com/'),
	array('vimeo','A popular video-centric social networking site.','http://www.vimeo.com/'),
	array('canon','Imaging and optical technology manufacturer.','http://www.canon.com/')
);


// Randomizing the order of sponsors:

shuffle($sponsors);

?>



<div id="main">

	<div class="sponsorListHolder">

		
        <?php
			
			// Looping through the array:
			
			foreach($sponsors as $company)
			{
				echo'
				<div class="sponsor" title="Click to flip">
					<div class="sponsorFlip">
						<img src="myaddons/sponsorpage/img/sponsors/'.$company[0].'.png" alt="More about '.$company[0].'" />
					</div>
					
					<div class="sponsorData">
						<div class="sponsorDescription">
							'.$company[1].'
						</div>
						<div class="sponsorURL">
							<a href="'.$company[2].'">'.$company[2].'</a>
						</div>
					</div>
				</div>
				
				';
			}
		
		?>

        
        
    	<div class="clear"></div>
    </div>

</div>

<p class="note">None of these companies are actually sponsors of Tutorialzine.</p>















{$footer}
</body>
</html>
and that does not work I tryed getting it localy from server and from google thats why the p was left off the http

well the site I am trying to get this to work is
www.howmanstest(dot)co(dot)cc
and the script that is not working for me can be found at
www.howmanstest(dot)co(dot)cc/testpage.php

Any help would be appreciated
Thank you
In your myaddons/sponsorpage/script.js change this:

At the very top where you have this:

$(document).ready(function(){

Remove that line and replace it with this:

jQuery.noConflict();
jQuery(document).ready(function($) {

There are also other things I noticed in your header that would cause some problems:

You are calling the jquery library multiple times, once from the api and the other time from your site:

<script type="text/javascript" src="htt://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script type="text/javascript" src="htt://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>

<script type="text/javascript" src="myaddons/sponsorpage/jquery-1.6.1.min.js"></script>
<script>
    jQuery.noConflict();
</script>
<script type="text/javascript" src="myaddons/sponsorpage/jquery-ui-1.8.13.custom.min.js"></script>

Although the calls from the api are incorrect as its using htt instead of http but if you did that so that they don't get loaded, better to remove the entire line than have a resource thats not available.

Lastly, this line has an extra </script> at the end:

<script type="text/javascript" src="myaddons/sponsorpage/script.js"></script></script>
G33K's covered everything, but I've just got to ask: why are you calling both 1.6.0 and 1.6.1? You only need one copy of the library.
Thank you all for this info it did the trick to help to me. I got it working now just got to fix a few things.

G33K
Is it better to use api or call from server

Thank you once again for your time
It's supposed to be better to use the API as it's faster. I've never really noticed a major difference between local and external hosting though.
Its really your personal preference, I have not noticed any major difference in speed between using the api or saving it and calling it from the same site, despite people saying the api's supposed to be faster. I personally prefer to save it on the site and call it locally just so that the site can be self dependent.
I think thats a good idea so if site with api goes down it will still work correctly

Thank you G33K