Archive for the ‘Jquery’ Category

h1

JQuery focus() after last character in textbox not woking in IE – Solution

May 7, 2015

In other browsers $(‘#TextBox’).focus() this code will work. for IE we need to do something special!!! in code

Code :

Create a function:

(function($){
$.fn.setCursorToTextEnd = function() {
$initialVal = this.val();
this.val($initialVal + ‘ ‘);
this.val($initialVal);
};
})(jQuery);

also we need to use setTimeout.

setTimeout(function() {
$(‘#TextBox’).focus();$(‘#TextBox’).setCursorToTextEnd();
}, 100);

Source 1
Source 2

h1

Check a classname exist

January 29, 2015

Check the html object is having a particular class :

if($.inArray(‘classname’, $(obj)[0].classList) > -1)
{
///class is available
}
h1

Ignore Validation For Hidden Controls

April 3, 2012

Ignore the validation for Hidden Controls just include This:

Javascript:

$(document).ready(function () {
$(‘#form1’).validate({ ignore: ‘:hidden’ });
});

h1

Colspan in JQgrid Header

November 26, 2011

In JQgrid header colspan option is presently not available.
But we can do it using following code

HTML :

<table id=”list1″>

</table>

<div id=”pager1″>

</div>

Javascript :

$(document).ready(function()

{

jQuery(“#list1”).jqGrid({

url:’test.aspx’,

datatype: “json”,

height: ‘auto’,

colNames: [‘col1′,’ col2′,’ col3′,’ col4′,’ col5′,’ col6′,

colModel:[ . . . ],

. . .

caption : “Header Colspan”

});

var SuperHeader = ‘<tr id=”super_header” class=”ui-jqgrid-labels” role=”rowheader”>’;

SuperHeader += ‘<th class=”ui-state-default ui-th-column ui-th-ltr”  style=”width: 145px;”></th>’;

SuperHeader += ‘<th class=”ui-state-default ui-th-column ui-th-ltr”  style=”width: 143px;”></th>’;

SuperHeader += ‘<th class=”ui-state-default ui-th-column ui-th-ltr” colspan=”2″  style=”width: 192px;”>Col 3 & 4</th>’;

SuperHeader += ‘<th class=”ui-state-default ui-th-column ui-th-ltr” colspan=”2″  style=”width: 192px;”> Col 5 & 6</th>’;

 

$(‘#gbox_list1’).find(‘.ui-jqgrid-labels’).before(SuperHeader);

}