www.webdeveloper.com
Results 1 to 5 of 5

Thread: noob needs help with jquery & mootools in joomla

  1. #1
    Join Date
    Feb 2010
    Posts
    2

    noob needs help with jquery & mootools in joomla

    Hi all,

    I am a tester in configuration manager by profession so I know a bit about code, but I am not a developer. I can write batch and shell scripts and I am good with markup languages, but I know very little about javascript. I guess I know just enough to be dangerous. But I am trying to learn and all help will be greatly appreciated.

    I have searched for an answer to this on the forum, but couldn't find anything I could understand.

    I am trying to integrate a jquery script called livetwitter into a Joomla template called Iridium by RocketTheme. The Joomla template uses mootools which I understand is a different framework.

    I have read that there are several hacks and plugins you can use with joomla to allow jquery to run. However, I dont understand what I must change to the call in the html to the jquery script. This is how the call from the developers site looks:

    Code:
    <div id="twitterUserTimeline" class="tweets"></div>
    	<script type="text/javascript">
    
    		// Basic usage
    		$('#twitterSearch').liveTwitter('bacon', {limit: 5, rate: 5000});
    		$('#twitterUserTimeline').liveTwitter('elektronaut', {limit: 5, refresh: false, mode: 'user_timeline'});
    
    		// Changing the query
    		$('#searchLinks a').each(function(){
    			var query = $(this).text();
    			$(this).click(function(){
    				// Update the search
    				$('#twitterSearch').liveTwitter(query);
    				// Update the header
    				$('#searchTerm').text(query);
    				return false;
    			});
    		});
    
    	</script>
    (I hope that is all indented correctly)

    Now I *think* with my dangerously small amount of knowledge that the problem is something to do with that "$" and the wrong javascript library being loaded... and that I need to specify a call to the jquery library.

    The livetwitter script lives in the /js folder and is called jquery.livetwitter.js

    I have emailed the author of the livetwitter scipt for advice, and been through the comments and docs for every jquery joomla plugin. None of them explain how I must change the above commands.

    I hope that explains the situation and problem I am having. All help greatly appreciated.

    Many thanks in advance.
    John

  2. #2
    Join Date
    Feb 2010
    Location
    Amsterdam
    Posts
    174
    i think your right about the wrong library beeing loaded, check

    http://docs.jquery.com/Using_jQuery_...ther_Libraries

  3. #3
    Join Date
    Feb 2010
    Posts
    2
    Hi Gozzy, thanks for replying.

    So I would amend the markup code to...

    <code>
    <!-- Begin twittersearch -->
    <div id="twitterSearch"></div>
    <script type="text/javascript">
    <script src="/js/jquery.livetwitter.min.js"></script>
    <script src="/js/jquery.livetwitter.js"></script>
    jQuery.noConflict(); <!-- suggested hack to force the following to use jquery -->
    $('#twitterSearch').liveTwitter('bacon', {limit: 5, rate: 5000});
    $('#twitterUserTimeline').liveTwitter('elektronaut', {limit: 5, refresh:
    </script>
    <!-- End twittersearch -->
    </code>

    ....... ???

    I have done that, and there is no noticeable change to the page.

  4. #4
    Join Date
    May 2010
    Posts
    1
    Hi sugarman,

    I'm not sure about joomla, but I had similar problems using JQuery in DotNetNuke.

    Step 2: Initialize jQuery
    DNN has name conflict issues with jQuery so the following line is needed (thanks to Steve Johnson at Abstract Coder for this tidbit):

    var $j = jQuery.noConflict();
    I included this in my utilities.js file outside of any functions.

    Step 3: Call jQuery Functions
    It is important to note that all of your calls to jQuery functions will use this $j variable instead of the normal, single $ you will find documented just about everywhere. So for example, the document ready function will look like this:

    $j(document).ready(function() {
    //your code here
    });
    Now you can write your normal javascript code and call jQuery functions throughout. Just remember to use the $j variable.
    http://randallhook.com/2009/09/16/ad...etnuke-module/

    This might help.
    Ruairi

  5. #5
    Join Date
    Apr 2010
    Location
    UK
    Posts
    117
    I'm also a tester, not a developer, but I know enough to know that if this is typical of the way they use jQuery:
    Code:
    		// Changing the query
    		$('#searchLinks a').each(function(){
    			var query = $(this).text();
    			$(this).click(function(){
    				// Update the search
    				$('#twitterSearch').liveTwitter(query);
    				// Update the header
    				$('#searchTerm').text(query);
    				return false;
    			});
    		});
    You probably want to avoid the rest of their code like the plague.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles