Skip to main content

Posts

Showing posts with the label jquery

New Function disableToggle to toggle disable on and off

New Function disableToggle to toggle disable on and off similar to slideToggle /********************* Function:disableToggle author:Mukesh License: Void of any license **********************/ $.fn.disableToggle = function() { if(($(this).attr("disabled")=="disabled") ($(this).attr("disabled")==true)) { $(this).removeAttr("disabled"); } else { $(this).attr("disabled","disabled"); } }; This function can be called as $("#element-id").disableToggle(); where element_id is the id of the element. For e.g., $("#edit-name").disableToggle();

Callback function to run after any specific ajax request that is predefined

Whenever any homework needs to be done after any ajax request has been loaded then this approach can be utilized. For e.g. whenever any title of table derived from liberation_make_table is clicked for sorting the columns then an ajax request is made. So if the table is loaded in div with id "maketable-1" Then suppose some steps are to carried out after ajax request is loaded onto that table. An alert needs to be displayed when the ajax request is completed Then this section can be added: $("#maketable-1").ajaxComplete(function(event,request, settings){ alert("hello"); });

Discovering jQuery

$() is the accessor for jquery via which DOM elements can be accessed. and within the round bracket an text has to be entered. That text is called selector. This text can be anything and if the text is not supplied then this will apply for the whole document just adding content