Fixes #96, When notify() is called for a new note, getNote() on the item returns false

Item.save() changed to not call notify() if a transaction is in progress, which is totally going to trip someone up at some point, and probably me, but it's better than a new parameter
This commit is contained in:
Dan Stillman 2006-06-28 15:47:58 +00:00
parent 965f4c3c0a
commit b75376c1c1

View file

@ -364,6 +364,10 @@ Scholar.Item.prototype.setField = function(field, value, loadIn){
/* /*
* Save changes back to database * Save changes back to database
*
* Note: Does not call notify() if transaction is in progress
*
* Returns true on item update or itemID of new item
*/ */
Scholar.Item.prototype.save = function(){ Scholar.Item.prototype.save = function(){
if (!this.hasChanged()){ if (!this.hasChanged()){
@ -739,11 +743,15 @@ Scholar.Item.prototype.save = function(){
Scholar.Items.reload(this.getID()); Scholar.Items.reload(this.getID());
if (isNew){ if (isNew){
Scholar.Notifier.trigger('add', 'item', this.getID()); if (!Scholar.DB.transactionInProgress()){
Scholar.Notifier.trigger('add', 'item', this.getID());
}
return this.getID(); return this.getID();
} }
else { else {
Scholar.Notifier.trigger('modify', 'item', this.getID()); if (!Scholar.DB.transactionInProgress()){
Scholar.Notifier.trigger('modify', 'item', this.getID());
}
return true; return true;
} }
} }