Skip to content

Commit

Permalink
Switch to htmx requests for explicit form.submit() calls
Browse files Browse the repository at this point in the history
This fixes issues like changing autocomplete queue input would create a
ticket instead of refreshing the form in QuickCreate.
  • Loading branch information
sunnavy committed Jan 16, 2025
1 parent 8c19dd5 commit b176c0a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions share/html/Admin/Elements/SelectNewGroupMembers
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jQuery(function(){
// Auto-submit once a user is chosen
jQuery("#"+<% $Name |n,j%>+"Users").on("autocompleteselect", function( event, ui ) {
jQuery(event.target).val(ui.item.value);
jQuery(event.target).closest("form").submit();
htmx.trigger(this.form, 'submit');
});
});
</script>
Expand All @@ -74,7 +74,7 @@ jQuery(function(){
// Auto-submit once a group is chosen
jQuery("#"+<% $Name |n,j%>+"Groups").on("autocompleteselect", function( event, ui ) {
jQuery(event.target).val(ui.item.value);
jQuery(event.target).closest("form").submit();
htmx.trigger(this.form, 'submit');
});
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion share/html/Articles/Elements/BeforeMessageBox
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

% if ( $ARGS{$name_prefix .'Articles-Include-Topic'} ) {
<&| /Elements/LabeledValue, Label => loc('Select an Article from [_1]', $included_topic->Name) &>
<select name="IncludeArticleId" onchange="this.form.submit()" class="form-select selectpicker">
<select name="IncludeArticleId" onchange="htmx.trigger(this.form, 'submit')" class="form-select selectpicker">
<option value="" selected>-</option>
% while ( my $art = $topic_articles->Next ) {
<option value="<% $art->id %>"><%$art->Name||loc('(no name)')%>: <%$art->Summary%></option>
Expand Down
2 changes: 1 addition & 1 deletion share/static/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ window.RT.Autocomplete.bind = function(from) {
if ( what === 'Queues' ) {
form.find('input[name=QueueChanged]').val(1);
}
form.submit();
htmx.trigger(this.form, 'submit');
};
}

Expand Down

0 comments on commit b176c0a

Please sign in to comment.