Open buttflattery opened 5 years ago
Hi there,
You can try using the jQuery Migrate Plugin to add in support for any missing jQuery methods or properties that were removed as jQuery was developed into newer versions.
In my case, I was receiving errors regarding event.props
being undefined.
@drewminns i aint getting any errors on console i dont think jquery migrate could work in this situation other than the one you pointed out you were facing
Just dealt with this myself - $(document).on('ready')
was deprecated in jQuery 3.0, and even before that, the handler wouldn't run anyway if the DOM is ready before the event is attached: discussed in the documentation here: https://api.jquery.com/ready/ under the list of ways to attach a function that will run when the DOM is ready. (Deprecation note here: https://jquery.com/upgrade-guide/3.0/#breaking-change-on-quot-ready-quot-fn-removed)
I wound up doing something like this:
handler = function() { ... }
$( handler )
$(document).on('pjax:end', handler)
I went to file a PR to the README here, but realized the ready
event handler has never received any arguments (as shown in the jquery pjax README), so I'm not sure what event.target
in the documentation refers to in the case of the ready
event firing.
Just dealt with this myself -
$(document).on('ready')
was deprecated in jQuery 3.0, and even before that, the handler wouldn't run anyway if the DOM is ready before the event is attached: discussed in the documentation here: https://api.jquery.com/ready/ under the list of ways to attach a function that will run when the DOM is ready. (Deprecation note here: https://jquery.com/upgrade-guide/3.0/#breaking-change-on-quot-ready-quot-fn-removed)I wound up doing something like this:
handler = function() { ... } $( handler ) $(document).on('pjax:end', handler)
I went to file a PR to the README here, but realized the
ready
event handler has never received any arguments (as shown in the jquery pjax README), so I'm not sure whatevent.target
in the documentation refers to in the case of theready
event firing.
@amywieliczka Could you explain a little more on this with your fix. I wasn't sure how to implement what your fix
I found this to be the easiest option
$(document).on('pjax:end', function(event) {
// my code here
}).trigger('pjax:end');
basically triggers the events attached to pjax:end
The documented code does not work as mentioned
The above code does not call the
initializeMyPlugin()
on the first page load with jquery 3.4.1 or jquery-2.2.4,i am using the following piece of of code
and the
loader()
function is never called on the first page load, only called onpjax:end
. i am using this code in Yii2 framework and the output is like below