Unable to register function for parameter in pjax

Pjax will not allow me to specify functions as an option when called directly.

$(document).on('click', 'a.inferno-preview', function(event) { return $.pjax.click(event, { container: '#preview-overlay', fragment: '#preview-overlay', send: function() { return $('#preview-overlay').removeClass('hidden'); }, complete: function() {} }); }); 

In this case, the send and complete functions are not executed, and the container and fragment work well. Why is this and what do I need to do to make Pjax recognize my functions?

By the way: I can’t use the usual form of using Pjax , I need more control over what is happening, so I need to use $ .pjax. click an object. However, this will work normally with functions in a general way, as in the following:

 $(document).pjax('a.inferno-preview', '#preview-overlay', { send: function() { alert('this will work.'); } }); 
+6
source share
1 answer

In pjax, send and complete do not trigger events if the request is received from the cache, so you will not get an overlay. Instead, use success or complete depending on your specific use case.

0
source

Source: https://habr.com/ru/post/959261/


All Articles