From e807bb824dd4030cacad0bd3b340ec32649d66fd Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 18 Jun 2012 22:41:54 +0000 Subject: [PATCH] Correctly return {app, id} or just id, even if value is empty --- etemplate/js/et2_widget_link.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/etemplate/js/et2_widget_link.js b/etemplate/js/et2_widget_link.js index b311105ca4..fb375743f6 100644 --- a/etemplate/js/et2_widget_link.js +++ b/etemplate/js/et2_widget_link.js @@ -458,7 +458,8 @@ var et2_link_entry = et2_inputWidget.extend({ { // Clear self.search.autocomplete("close"); - self.search.val(""); + self.set_value(""); + self.search.trigger("change"); } self.search.focus(); }) @@ -505,17 +506,10 @@ var et2_link_entry = et2_inputWidget.extend({ }, getValue: function() { - return this.options.value; + return this.options.application ? this.value.id : this.value; }, set_value: function(_value) { - if(!_value || _value.length == 0) - { - this.search.text(""); - this.clear.hide(); - this.value = {}; - return; - } if(typeof _value == 'string') { if(_value.indexOf(",") > 0) _value = _value.replace(",",":"); @@ -536,6 +530,13 @@ var et2_link_entry = et2_inputWidget.extend({ }; } } + if(!_value || _value.length == 0) + { + this.search.val(""); + this.clear.hide(); + this.value = _value; + return; + } this.clear.show(); if(!_value.app) _value.app = this.options.application; if(typeof _value != 'object' || !(_value.app && _value.id)) @@ -643,6 +644,8 @@ var et2_link_entry = et2_inputWidget.extend({ this.clear.show(); event.data.search.val(selected.item.label); + // Fire change event + this.search.change(); }, /**