Open arogachev opened 7 years ago
How would you do it? That's BC breaking for sure, right?
@samdark At least we can have properties like enableCsrfHandler
, enableRedirectHandler
and so on, then wrap these init
function calls with if (pub.enableSomeFeature) { }
kind of checks and give them default true
values to prevent BC break. Hovewer setting them can be a problem, see #13295. I thought about passing them through data attributes or decoupling this part from yii.js
:
jQuery(function () {
yii.initModule(yii);
});
and initialize it along with other widgets maybe.
As for destroy part and other nuances, it requires more deeper thinking. But in case of some radical changes we can always defer this issue to 2.1.
Yes, using data attributes sounds great.
I found this issue during writing tests for
yii.js
.Currently the
yii.js
is initialized right when the DOM is ready and applies all functionality:and:
First of all, the user might not need all provided functionality. Let's say he doesn't need "data methods" functionality or "script filter" functionality, but still needs to automatically add CSRF or perform redirects after AJAX.
There is no way to configure that, we either get all or nothing.
Also there is no "destroy" functionality (because it's not a jQuery plugin I guess), so the only way to deactivate something is to deeply investigate the code and understand what it does and then deactivate proper event handlers, etc. This is not user-friendly at all. And I'm not sure if it's possible to deactivate code registered with
$.ajaxPrefilter
(unless it's done in the callback itself under certain conditions).So the proposal is to add more flexible initialization and destroy functionality to temporarily deactivate something and initialize again.