Posts

Showing posts from November, 2012

Turn off autocomplete in input fields

In some situations like in promotional code field on Cart page or username in Login page we may not want to show autocomplete below input field when we type some thing or double click on input fields. All we need to do is just add the autocomplete='off' attribute in input field. After entering this code, input field will look like this <input name='couponcode' type='text' autocomplete='off' /> That's it we have turnoff autocomplete in input field.

Add tinyMCE editor in magento custom module

If we have created a custom module using Magento Module creator means, it will not contain 'wysiwyg(tinyMCE)' editor feature. We can add the 'wysiwyg' editor in custom module within 2 steps.

Add success or error message using magento session

Error message Set error message for front page. $message = $this->__('Got an error'); Mage::getSingleton('core/session')->addError($message); Set error message for admin page. $message = $this->__('Got an error'); Mage::getSingleton('adminhtml/session')->addError($message); Success message Set success message for front page. $message = $this->__('Got an error'); Mage::getSingleton('core/session')->addSuccess($message); Set success message for admin page. $message = $this->__('Got an error'); Mage::getSingleton('adminhtml/session')->addSuccess($message); If you are unable to view the error/success message, add the function session_write_close() after setting message. I got such problem while using with redirect method. Nitroware solved this problem.Now the new snippet will look like below, $message = $this->__('Got an error'); Mage::getSingleton('adminhtml/session')->addError(

jQuery setTimeout() function

If we want to run a block of code after a specified time means we can use jQuery setTimeout() method. What it will do is, it will run specified code at specified millisecond. Syntax for this method is setTimeout(code,milliseconds) . jQuery(document).ready(function () { jQuery('.submit').click(function(){ var T = setTimeout(showAlert, 3000); }); });function showAlert(){ alert("Its fired after 3 seconds"); } Html code <button id="submit">Submit</button> In the above code, function showAlert() will be called after 3 seconds after clicking submit id.We can clear the time which is set by setTimeout() by using this method clearTimeout(id) . It accepts one parameter which is returned by the setTimeout() . ie., We can stop the setTimeout() timer by passing its id 'T' to the clearTimeout() method like this clearTimeout(T) . 'T' is the id, which is assigned to the setTimeout() method. Click here for live demo Note: D