Trigger pjax request upon JS form submit #201
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?
I have activated pjax on a form as follows:
Now within my form I have an hidden input field. I have a dropdown outside of the form which can set the value of this hidden input dynamically. So for example I have:
JS:
As you can see, I am submitting the form when the dropdown value changes, but this results in a non-pjax request. How can I make it trigger the pjax request when I submit the form via JS?
OK I found a solution. Instead of triggering a form submit event, trigger a click on the submit button in the form:
$('#search-form button').click();Whilst this now works, I still think it would be more elegant to trigger a form submit event. Is this something that can be looked in to?
You can try something like this