Skip to content
This repository has been archived by the owner on Jul 11, 2020. It is now read-only.

Commit

Permalink
fix: previous commit broke for items that were added after make_edita…
Browse files Browse the repository at this point in the history
…ble() was called.
  • Loading branch information
knipknap committed Oct 11, 2012
1 parent 4b68b72 commit bdaea23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions index.html
Expand Up @@ -65,8 +65,8 @@
"cursorAt": {'right': -5}, "cursorAt": {'right': -5},
"stop": function(event, ui) { "stop": function(event, ui) {
var cls = spiffform_elements[$(this).attr('name')]; var cls = spiffform_elements[$(this).attr('name')];
form.insert_at(event, new cls()); var obj = form.insert_at(event, new cls());
this.select(obj); form.select(obj);
} }
}); });
}); });
Expand Down
9 changes: 4 additions & 5 deletions spiffform/spiffform.js
Expand Up @@ -1097,10 +1097,12 @@ var SpiffForm = function(div) {
var handle = obj.get_handle(); var handle = obj.get_handle();
var elem = $('<li class="spiffform-item spiffform-item-' + handle + '"></li>'); var elem = $('<li class="spiffform-item spiffform-item-' + handle + '"></li>');
elem.data('obj', obj); elem.data('obj', obj);
obj.attach(elem);
elem.click(function(e) { elem.click(function(e) {
if (!$(e.target).is('input,textarea,select'))
that._div.find(':focus').blur();
return that.trigger('clicked', [e, obj]); return that.trigger('clicked', [e, obj]);
}); });
obj.attach(elem);
return elem; return elem;
}; };


Expand Down Expand Up @@ -1149,6 +1151,7 @@ var SpiffForm = function(div) {
// Dropped on the form, but not on the element list. // Dropped on the form, but not on the element list.
this._div.find('.spiffform-elements').append(elem); this._div.find('.spiffform-elements').append(elem);
} }
return obj;
}; };


this.make_editable = function(panel) { this.make_editable = function(panel) {
Expand All @@ -1172,15 +1175,11 @@ var SpiffForm = function(div) {
that.unselect(); that.unselect();
}); });
that.bind('clicked', function(e, obj) { that.bind('clicked', function(e, obj) {
that._div.find(':focus').blur();
that.select(obj); that.select(obj);
return false; return false;
}); });


// Initialize keyboard events. // Initialize keyboard events.
that._div.find('input,select,textarea').click(function() {
return false;
});
$(document).keydown(function(event) { $(document).keydown(function(event) {
if ($('input,select,textarea').is(':focus')) if ($('input,select,textarea').is(':focus'))
return; return;
Expand Down

0 comments on commit bdaea23

Please sign in to comment.