Archive

Posts Tagged ‘jquery’

jQuery1.5 Cheat Sheet

April 4th, 2011 prakash No comments

jQuery Cheat Sheet for version 1.5, use it for quick reference on learning jquery.
Launch PDF file.

Finding n-th level of sibling on DOM with jquery

March 20th, 2011 prakash No comments

By clicking on an element in DOM, to get the which indexed number of the sibling, you’ll need to use jquery’s .index() method which is easy and useful too.
Let’s give an example,
HTML :

 <ul>
     <li>first</li>
     <li>second</li>
     <li>third</li>
 </ul>

Javascript:

$('li').click(function () {
    alert($(this).index());
});

Enjoy jquery

Categories: Uncategorized Tags: ,

Implementing Jquery in Joomla

February 5th, 2011 prakash No comments

Joomla Uses Mootools as it’s javascript library by default, so we’ll need to use the jquery’s power of flexibility ie, jquery noConflict. Below are the examples how to use it.

In admin :

  1. $document =JFactory::getDocument();
  2. $document->addScript('location_to_jquery/jquery-min.js');
  3. $scripts = "jQuery.noConflict()";
  4. $document->addScriptDeclaration($scripts);

In Site :

from template :

  1. <script type="text/javascript" src="<?php echo $this->baseurl ;?>/templates/<?php echo $this->template?>/js/jquery-min.js">
  2. jQuery.noConflict();
  3. </script >
  4. // insert this code inside the <head> tag before <jdoc:include type="head" > tag

From module and component:

  1. $document = JFactory::getDocument();
  2. $document->addScript('location_to_jquery/jquery-min.js');
  3. $scripts = "jQuery.noConflict()";
  4. $document->addScriptDeclaration($scripts);