Skip to content
This repository
Browse code

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...
commit 08ba34b0b53834b7328f6667f0cdbe9b777a513b 1 parent bbc4db7
Tony Tomov authored
1  js/grid.celledit.js
@@ -81,6 +81,7 @@ $.jgrid.extend({
81 81 $t.p.beforeEditCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol);
82 82 }
83 83 $(cc).html("").append(elc).attr("tabindex","0");
  84 + $.jgrid.bindEv( elc, opt, $t);
84 85 window.setTimeout(function () { $(elc).focus();},0);
85 86 $("input, select, textarea",cc).bind("keydown",function(e) {
86 87 if (e.keyCode === 27) {
35 js/grid.common.js
@@ -260,24 +260,23 @@ $.extend($.jgrid,{
260 260 if($.isFunction(mopt.afterOpen) ) { mopt.afterOpen(); }
261 261 try{ $("#info_dialog").focus();} catch (m){}
262 262 },
  263 + bindEv: function (el, opt, $t) {
  264 + if($.isFunction(opt.dataInit)) {
  265 + opt.dataInit.call($t,el);
  266 + }
  267 + if(opt.dataEvents) {
  268 + $.each(opt.dataEvents, function() {
  269 + if (this.data !== undefined) {
  270 + $(el).bind(this.type, this.data, this.fn);
  271 + } else {
  272 + $(el).bind(this.type, this.fn);
  273 + }
  274 + });
  275 + }
  276 + },
263 277 // Form Functions
264 278 createEl : function(eltype,options,vl,autowidth, ajaxso) {
265 279 var elem = "", $t = this;
266   - function bindEv (el, opt) {
267   - if($.isFunction(opt.dataInit)) {
268   - opt.dataInit.call($t,el);
269   - }
270   - if(opt.dataEvents) {
271   - $.each(opt.dataEvents, function() {
272   - if (this.data !== undefined) {
273   - $(el).bind(this.type, this.data, this.fn);
274   - } else {
275   - $(el).bind(this.type, this.fn);
276   - }
277   - });
278   - }
279   - return opt;
280   - }
281 280 function setAttributes(elm, atr, exl ) {
282 281 var exclude = ['dataInit','dataEvents','dataUrl', 'buildSelect','sopt', 'searchhidden', 'defaultValue', 'attr'];
283 282 if(typeof(exl) != "undefined" && $.isArray(exl)) {
@@ -303,7 +302,6 @@ $.extend($.jgrid,{
303 302 if(vl==' ' || vl==' ' || (vl.length==1 && vl.charCodeAt(0)==160)) {vl="";}
304 303 elem.value = vl;
305 304 setAttributes(elem, options);
306   - options = bindEv(elem,options);
307 305 $(elem).attr({"role":"textbox","multiline":"true"});
308 306 break;
309 307 case "checkbox" : //what code for simple checkbox
@@ -329,7 +327,6 @@ $.extend($.jgrid,{
329 327 $(elem).attr("offval",cbval[1]);
330 328 }
331 329 setAttributes(elem, options, ['value']);
332   - options = bindEv(elem,options);
333 330 $(elem).attr("role","checkbox");
334 331 break;
335 332 case "select" :
@@ -360,7 +357,6 @@ $.extend($.jgrid,{
360 357 if(a) {
361 358 $(elem).append(a);
362 359 setAttributes(elem, options);
363   - options = bindEv(elem,options);
364 360 if(typeof options.size === 'undefined') { options.size = msl ? 3 : 1;}
365 361 if(msl) {
366 362 ovm = vl.split(",");
@@ -424,7 +420,6 @@ $.extend($.jgrid,{
424 420 }
425 421 }
426 422 setAttributes(elem, options, ['value']);
427   - options = bindEv(elem,options);
428 423 }
429 424 break;
430 425 case "text" :
@@ -437,7 +432,6 @@ $.extend($.jgrid,{
437 432 elem.type = eltype;
438 433 elem.value = vl;
439 434 setAttributes(elem, options);
440   - options = bindEv(elem,options);
441 435 if(eltype != "button"){
442 436 if(autowidth) {
443 437 if(!options.size) { $(elem).css({width:"98%"}); }
@@ -450,7 +444,6 @@ $.extend($.jgrid,{
450 444 elem = document.createElement("input");
451 445 elem.type = eltype;
452 446 setAttributes(elem, options);
453   - options = bindEv(elem,options);
454 447 break;
455 448 case "custom" :
456 449 elem = document.createElement("span");
1  js/grid.formedit.js
@@ -494,6 +494,7 @@ $.jgrid.extend({
494 494 }
495 495 $("td:eq("+(cp-2)+")",trdata[0]).html( typeof frmopt.label === 'undefined' ? obj.p.colNames[i]: frmopt.label);
496 496 $("td:eq("+(cp-1)+")",trdata[0]).append(frmopt.elmprefix).append(elc).append(frmopt.elmsuffix);
  497 + $.jgrid.bindEv( elc, opt, $t);
497 498 retpos[cnt] = i;
498 499 cnt++;
499 500 }
1  js/grid.inlinedit.js
@@ -79,6 +79,7 @@ $.jgrid.extend({
79 79 $(elc).addClass("editable");
80 80 if(treeg) { $("span:first",this).append(elc); }
81 81 else { $(this).append(elc); }
  82 + $.jgrid.bindEv( elc, opt, $t);
82 83 //Again IE
83 84 if(cm[i].edittype == "select" && typeof(cm[i].editoptions)!=="undefined" && cm[i].editoptions.multiple===true && typeof(cm[i].editoptions.dataUrl)==="undefined" && $.browser.msie) {
84 85 $(elc).width($(elc).width());

0 comments on commit 08ba34b

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