Inline scripts can trigger pjax:complete event before loadUrl does
#117
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
After an inline external script that has been processed by
lib/eval-script.jsloads, it triggers apjax:completeevent which can sometimes fire beforeloadUrltriggers its ownpjax:completeandpjax:successevents.The documentation doesn't suggest that we should be firing multiple
pjax:completeevents, so I think we should either change the event being fired by these injected scripts (to something likepjax:complete:external) or remove them entirely -- is there a use case for them to fire events?Is this related to #35?
Any fix for #35 will almost certainly have to hook into the script onload events defined in
lib/eval-script.js, but the two issues don't otherwise have the same cause or solution. Might be good to try and fix both at the same time, but this one is probably the easier of the two to resolve.I'm not so sure this is closed. I've manually invoked
.loadUrlandpjax:completeis firing before and after. Commenting outpjax.loadUrl(url, options)seems to still work and remove the double firing, but I'm not sure this is the best approach. The following is my invocation withpjax.loadUrlcommented out:Like I said, it seems that everything is still running with regards to the pjax functionality. Am I missing something?
@Bran99 If you're using Pjax, you don't need click handlers; Pjax handles that for you. You also don't need to specify switch functions unless you want custom behavior.
Try replacing the above code with just the Pjax constructor: