sync disabled and readonly statuses off original element even post creation
This commit is contained in:
parent
22dba24881
commit
5374b8799b
34
select2.js
34
select2.js
@ -634,7 +634,11 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
// abstract
|
// abstract
|
||||||
destroy: function () {
|
destroy: function () {
|
||||||
var select2 = this.opts.element.data("select2");
|
var select2 = this.opts.element.data("select2");
|
||||||
|
|
||||||
|
if (this.propertyObserver) { delete this.propertyObserver; this.propertyObserver = null; }
|
||||||
|
|
||||||
if (select2 !== undefined) {
|
if (select2 !== undefined) {
|
||||||
|
|
||||||
select2.container.remove();
|
select2.container.remove();
|
||||||
select2.dropdown.remove();
|
select2.dropdown.remove();
|
||||||
select2.opts.element
|
select2.opts.element
|
||||||
@ -810,11 +814,39 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
*/
|
*/
|
||||||
// abstract
|
// abstract
|
||||||
monitorSource: function () {
|
monitorSource: function () {
|
||||||
this.opts.element.bind("change.select2", this.bind(function (e) {
|
var el = this.opts.element, sync;
|
||||||
|
|
||||||
|
el.bind("change.select2", this.bind(function (e) {
|
||||||
if (this.opts.element.data("select2-change-triggered") !== true) {
|
if (this.opts.element.data("select2-change-triggered") !== true) {
|
||||||
this.initSelection();
|
this.initSelection();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
sync = this.bind(function () {
|
||||||
|
var enabled = this.opts.element.attr("disabled") !== "disabled";
|
||||||
|
var readonly = this.opts.element.attr("readonly") === "readonly";
|
||||||
|
|
||||||
|
enabled = enabled && !readonly;
|
||||||
|
|
||||||
|
if (this.enabled !== enabled) {
|
||||||
|
if (enabled) {
|
||||||
|
this.enable();
|
||||||
|
} else {
|
||||||
|
this.disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// mozilla and IE
|
||||||
|
el.bind("propertychange.select2 DOMAttrModified.select2", sync);
|
||||||
|
// safari and chrome
|
||||||
|
if (typeof WebKitMutationObserver !== "undefined") {
|
||||||
|
if (this.propertyObserver) { delete this.propertyObserver; this.propertyObserver = null; }
|
||||||
|
this.propertyObserver = new WebKitMutationObserver(function (mutations) {
|
||||||
|
mutations.forEach(sync);
|
||||||
|
});
|
||||||
|
this.propertyObserver.observe(el.get(0), { attributes:true, subtree:false });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user