mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Fixing button destroy bug
When you want to add a button to the CMS but don't want LeftAndMain to apply jQuery UI button to it we add the `data-button="true"` attribute to our button. The `onadd` function checks that this attribute does not exist before calling `this.button()`. The `onremove` incorrectly checks that this attribute does exist before calling `this.button('destroy')`. This should be checking that this attribute does not exist, just like the `onadd` function. What this causes is when you have a button with the `data-button` attribute a button is not created, but when you leave the page `destory` gets called on an item which doesn't exist. We end up with the following error: > Uncaught Error: cannot call methods on button prior to initialization; attempted to call method 'destroy' The other issue with this logic is buttons are never getting destroyed when `onremove` is called. The whole issue is caused by a missing `!` in the if statement. This change adds it in to fix the problem.
This commit is contained in:
parent
8c23b67b9f
commit
cd8904e045
@ -1081,7 +1081,7 @@ jQuery.noConflict();
|
||||
this._super();
|
||||
},
|
||||
onremove: function() {
|
||||
if(this.data('button')) this.button('destroy');
|
||||
if(!this.data('button')) this.button('destroy');
|
||||
this._super();
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user