Wednesday, February 27, 2013

Hide dropdown on clicking outside when using JQuery Toggle

This is slightly better, as it also check the parent(s) of the element being clicked:
$(document).click(function(e) {
    var target = e.target;

    if (!$(target).is('#menu') && !$(target).parents().is('#menu')) {
        $('#menu').hide();
    }
});

Call a Module inside a component



$modName = 'mod_refinesearch '; // not mod_mostread
$modTitle = 'Refine Search';
$mod = JModuleHelper::getModule($modName, $modTitle);
$content = JModuleHelper::renderModule($mod);
echo $content;

Friday, February 22, 2013

JQUERY GET CURRENT PAGE URL


$(document).ready(function() { &nbsp; &nbsp; //jquery &nbsp; &nbsp; $(location).attr('href'); &nbsp; &nbsp; //pure javascript &nbsp; &nbsp; var pathname = window.location.pathname; &nbsp; &nbsp; &nbsp; &nbsp; // to show it in an alert window &nbsp; &nbsp; alert(window.location); });<br />Javascript Functionfunction getAbsolutePath() { &nbsp; &nbsp; var loc = window.location; &nbsp; &nbsp; var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1); &nbsp; &nbsp; return loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length)); }

Dynamically checked radio button, based on 'value' attribute


$(function() {
    var $213 = "Yes";
    $("input[name=sv_213][value="+$213+"]").attr('checked', true);

    });

Refer : http://jsfiddle.net/CW8AC/

Tuesday, February 19, 2013

Monday, February 18, 2013

Find current template name in module


<?php
$app = JFactory::getApplication();
$templateDir = JURI::base() . 'templates/' . $app->getTemplate();
?>