|
61 | 61 |
|
62 | 62 | unbind: function()
|
63 | 63 | {
|
| 64 | + var self = this; |
64 | 65 | this.$element.unbind(".editly");
|
65 | 66 | this.$element.find("tbody td").each(function () {
|
66 |
| - $(this).removeAttr("tabindex"); |
| 67 | + if (self.options.editors[this.cellIndex] != null) { |
| 68 | + $(this).removeAttr("tabindex"); |
| 69 | + } |
| 70 | + else |
| 71 | + $(this).css("cursor", ""); |
| 72 | + |
67 | 73 | });
|
68 | 74 | for (var i = 0; i < this.options.editors.length; i++) {
|
69 | 75 | $(this.options.editors[i]).hide();
|
|
80 | 86 |
|
81 | 87 | var movement = function (element, keycode) {
|
82 | 88 | if (keycode === ARROW_RIGHT)
|
83 |
| - return element.next('td'); |
| 89 | + return element.next('td:tabindex'); |
84 | 90 | else if (keycode === ARROW_LEFT)
|
85 |
| - return element.prev('td'); |
| 91 | + return element.prev('td:tabindex'); |
86 | 92 | else if (keycode === ARROW_UP)
|
87 | 93 | return element.parent().prev().children().eq(element.index());
|
88 | 94 | else if (keycode === ARROW_DOWN)
|
|
157 | 163 |
|
158 | 164 | var showEditor = function (select) {
|
159 | 165 | var last = active;
|
160 |
| - active = self.$element.find('td:focus'); |
| 166 | + var newActive = self.$element.find('td:focus'); |
161 | 167 |
|
162 |
| - if (active.length) { |
| 168 | + if (newActive.length) { |
| 169 | + active = newActive; |
163 | 170 | template = self.options.editors[active[0].cellIndex];
|
164 | 171 | editor = template.is(":input") ? template : template.find(":input");
|
165 | 172 | validator = editor.parents("form").data('validator');
|
|
180 | 187 | }
|
181 | 188 | };
|
182 | 189 |
|
183 |
| - if (last != null) { |
| 190 | + if (last != null && last.length > 0) { |
184 | 191 | var lastTemplate = self.options.editors[last[0].cellIndex];
|
185 | 192 |
|
186 | 193 | if (lastTemplate != template) {
|
|
284 | 291 | };
|
285 | 292 |
|
286 | 293 | this.$element.find("tbody td").each(function () {
|
287 |
| - if (!this.tabIndex || this.tabIndex < 0) |
288 |
| - this.tabIndex = 0; |
| 294 | + if (self.options.editors[this.cellIndex] != null) { |
| 295 | + if (!this.tabIndex || this.tabIndex < 0) |
| 296 | + this.tabIndex = 0; |
| 297 | + } |
| 298 | + else |
| 299 | + $(this).css("cursor", "default"); |
289 | 300 | });
|
290 | 301 |
|
291 | 302 | $(this.$element).on("click.editly keypress.editly dblclick.editly", $.proxy(function (e) {
|
292 | 303 | if (doValidation()) {
|
293 |
| - if(active) |
| 304 | + if(active&&active.length>0) |
294 | 305 | saveActive();
|
295 | 306 | showEditor(true);
|
296 | 307 | } else {
|
|
307 | 318 | possibleMove.focus();
|
308 | 319 | }
|
309 | 320 | else if (e.which === ENTER) {
|
310 |
| - if (active != null && active.tagName == "INPUT") { |
| 321 | + if (active != null && active.length > 0 && active[0].tagName == "INPUT") { |
311 | 322 | possibleMove = movement($(e.target), e.shiftKey ? ARROW_UP : ARROW_DOWN)
|
312 | 323 | if (possibleMove.length > 0) {
|
313 | 324 | possibleMove.focus();
|
|
0 commit comments