Jaxel
Well-known member
I have a form field, with a username search field. This field has an AC autosubmit function:
I then prevent the default function on this field to stop the page reload and simply reload a tagged user list:
The oddity I am having is related to the dropdown list of usernames that shows up.
If I simply type in the username (ie: "Jaxel"), and hit enter on my keyboard,
However, if I instead click on the username in the dropdown menu that appears in the autocomplete search dropdown, it does not
Code:
<xf:form action="{{ link('ewr-medio/add-user', $media) }}" class="block" ajax="true" data-xf-init="medio-taguser">
<div class="block-container">
<h3 class="block-minorHeader">{{ phrase('EWRmedio_add_user') }}</h3>
<div class="block-body block-row">
<xf:textbox name="usernames" ac="single" id="media-adduser" data-autosubmit="true" />
</div>
</div>
</xf:form>
Code:
EWRmedio.TagUser = XF.Element.newHandler(
{
init: function()
{
XF.on(this.target, 'ajax-submit:response', this.response.bind(this));
},
response: function(e)
{
if (e.data.status == 'ok')
{
e.preventDefault();
XF.ajax('GET', e.data.redirect, {}, function(data)
{
if (data.html)
{
XF.setupHtmlInsert(data.html, (html, container) =>
{
document.querySelector('#media-userlinks').innerHTML = html.innerHTML;
document.querySelector('#media-adduser').value = '';
})
}
});
}
},
});
The oddity I am having is related to the dropdown list of usernames that shows up.
If I simply type in the username (ie: "Jaxel"), and hit enter on my keyboard,
e.preventDefault()
is activated and everything runs proper.However, if I instead click on the username in the dropdown menu that appears in the autocomplete search dropdown, it does not
e.preventDefault()
and it activates a page reload instead. Is this a regression error? This issue did not exist in XF2.2.