1
0
mirror of synced 2025-02-09 16:49:24 +03:00

add a rejectable select event. fixes #1053

This commit is contained in:
Igor Vaynberg 2013-04-09 19:53:11 -07:00
parent 931862c6ef
commit dc27a5b74d

View File

@ -964,6 +964,13 @@ the specific language governing permissions and limitations under the Apache Lic
}
},
// abstract
triggerSelect: function(data) {
var evt = $.Event("selected", { val: this.id(data), object: data });
this.opts.element.trigger(evt);
return !evt.isDefaultPrevented();
},
/**
* Triggers the change event on the source element
*/
@ -1974,6 +1981,9 @@ the specific language governing permissions and limitations under the Apache Lic
// single
onSelect: function (data, options) {
if (!this.triggerSelect(data)) { return; }
var old = this.opts.element.val(),
oldData = this.data();
@ -2407,6 +2417,9 @@ the specific language governing permissions and limitations under the Apache Lic
// multi
onSelect: function (data, options) {
if (!this.triggerSelect(data)) { return; }
this.addSelectedChoice(data);
this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });