Skip to content
Browse files

Calling the events in the editable element after it is added in the d…

…om. This fix the issue to use setTimout. Thanks to Oleg
  • Loading branch information...
1 parent bbc4db7 commit 08ba34b0b53834b7328f6667f0cdbe9b777a513b @tonytomov committed Nov 7, 2012
Showing with 17 additions and 21 deletions.
  1. +1 −0 js/grid.celledit.js
  2. +14 −21 js/grid.common.js
  3. +1 −0 js/grid.formedit.js
  4. +1 −0 js/grid.inlinedit.js
View
1 js/grid.celledit.js
@@ -81,6 +81,7 @@ $.jgrid.extend({
$t.p.beforeEditCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol);
}
$(cc).html("").append(elc).attr("tabindex","0");
+ $.jgrid.bindEv( elc, opt, $t);
window.setTimeout(function () { $(elc).focus();},0);
$("input, select, textarea",cc).bind("keydown",function(e) {
if (e.keyCode === 27) {
View
35 js/grid.common.js
@@ -260,24 +260,23 @@ $.extend($.jgrid,{
if($.isFunction(mopt.afterOpen) ) { mopt.afterOpen(); }
try{ $("#info_dialog").focus();} catch (m){}
},
+ bindEv: function (el, opt, $t) {
+ if($.isFunction(opt.dataInit)) {
+ opt.dataInit.call($t,el);
+ }
+ if(opt.dataEvents) {
+ $.each(opt.dataEvents, function() {
+ if (this.data !== undefined) {
+ $(el).bind(this.type, this.data, this.fn);
+ } else {
+ $(el).bind(this.type, this.fn);
+ }
+ });
+ }
+ },
// Form Functions
createEl : function(eltype,options,vl,autowidth, ajaxso) {
var elem = "", $t = this;
- function bindEv (el, opt) {
- if($.isFunction(opt.dataInit)) {
- opt.dataInit.call($t,el);
- }
- if(opt.dataEvents) {
- $.each(opt.dataEvents, function() {
- if (this.data !== undefined) {
- $(el).bind(this.type, this.data, this.fn);
- } else {
- $(el).bind(this.type, this.fn);
- }
- });
- }
- return opt;
- }
function setAttributes(elm, atr, exl ) {
var exclude = ['dataInit','dataEvents','dataUrl', 'buildSelect','sopt', 'searchhidden', 'defaultValue', 'attr'];
if(typeof(exl) != "undefined" && $.isArray(exl)) {
@@ -303,7 +302,6 @@ $.extend($.jgrid,{
if(vl==' ' || vl==' ' || (vl.length==1 && vl.charCodeAt(0)==160)) {vl="";}
elem.value = vl;
setAttributes(elem, options);
- options = bindEv(elem,options);
$(elem).attr({"role":"textbox","multiline":"true"});
break;
case "checkbox" : //what code for simple checkbox
@@ -329,7 +327,6 @@ $.extend($.jgrid,{
$(elem).attr("offval",cbval[1]);
}
setAttributes(elem, options, ['value']);
- options = bindEv(elem,options);
$(elem).attr("role","checkbox");
break;
case "select" :
@@ -360,7 +357,6 @@ $.extend($.jgrid,{
if(a) {
$(elem).append(a);
setAttributes(elem, options);
- options = bindEv(elem,options);
if(typeof options.size === 'undefined') { options.size = msl ? 3 : 1;}
if(msl) {
ovm = vl.split(",");
@@ -424,7 +420,6 @@ $.extend($.jgrid,{
}
}
setAttributes(elem, options, ['value']);
- options = bindEv(elem,options);
}
break;
case "text" :
@@ -437,7 +432,6 @@ $.extend($.jgrid,{
elem.type = eltype;
elem.value = vl;
setAttributes(elem, options);
- options = bindEv(elem,options);
if(eltype != "button"){
if(autowidth) {
if(!options.size) { $(elem).css({width:"98%"}); }
@@ -450,7 +444,6 @@ $.extend($.jgrid,{
elem = document.createElement("input");
elem.type = eltype;
setAttributes(elem, options);
- options = bindEv(elem,options);
break;
case "custom" :
elem = document.createElement("span");
View
1 js/grid.formedit.js
@@ -494,6 +494,7 @@ $.jgrid.extend({
}
$("td:eq("+(cp-2)+")",trdata[0]).html( typeof frmopt.label === 'undefined' ? obj.p.colNames[i]: frmopt.label);
$("td:eq("+(cp-1)+")",trdata[0]).append(frmopt.elmprefix).append(elc).append(frmopt.elmsuffix);
+ $.jgrid.bindEv( elc, opt, $t);
retpos[cnt] = i;
cnt++;
}
View
1 js/grid.inlinedit.js
@@ -79,6 +79,7 @@ $.jgrid.extend({
$(elc).addClass("editable");
if(treeg) { $("span:first",this).append(elc); }
else { $(this).append(elc); }
+ $.jgrid.bindEv( elc, opt, $t);
//Again IE
if(cm[i].edittype == "select" && typeof(cm[i].editoptions)!=="undefined" && cm[i].editoptions.multiple===true && typeof(cm[i].editoptions.dataUrl)==="undefined" && $.browser.msie) {
$(elc).width($(elc).width());

0 comments on commit 08ba34b

Please sign in to comment.
Something went wrong with that request. Please try again.