Pages

Friday, September 16, 2011

jQuery version of document.scrollIntoView with animation

$('html,body').animate({scrollTop: $([selector]).offset().top-[offsettop]},500);


Where [selector] is the css-patterned name or object (e.g. this ) of the target and [offsettop] is an integer to keep the browser a bit uplifted.

e.g.


$('html,body').animate({scrollTop: $("#description-section").offset().top-20 },500);


Tuesday, September 13, 2011

Movable Type: Getting the Loop Counter

<mt:if name="__counter__" op="mod" value="3" eq="0">Something HTML Output</mt:if>

So, the "__counter__"  is the way to find out the Loop count. It can be a loop, inside <mt:Entries> or what ever is.

In the Above code, if the counter%3 == 0, Some HTML Output will be t
he parsing output.

Saturday, September 10, 2011

Joomla! 1.5: Accessing a Model of a Component from a Module/Plugin or anywhere

JLoader::import('joomla.application.component.model');

JLoader::import( 'investment', JPATH_SITE . DS . 'components' . DS . 'com_<COMPONENT-NAME>' . DS . 'models' );

$model =& JModel::getInstance('<MODEL-CLASS-NAME>');

A blog commenter told the 2 line is not required but I can not make this working without the 2nd line.

It is also notable, that blog was using JPATH_ADMINISTRATOR, and mine was JPATH_SITE.

Wednesday, September 7, 2011

Executing JS code in Mootools Ajax Response

evalScripts: true

By default, Mootools 1.11, (that is default Joomla 1.5 JS library if not upgraded) keeps the Javascript evaluation OFF in the Ajax calling, that means evalScritps : false.

On a Joomla Project I fall into trouble with it. Later found, if this ajax setup parameter is set to true, the arrived JS codes are executed.