How to prevent jquery event from triggering in dropdown list provided that event is connected

I have a dropdown on my webpage with a jquery event related to a change event. When changing, I use ajax to load the partial view in a popup.

When a user uses the keyboard to navigate through the list of items, but then clicks a link to another part of the page, I instantly see my pop-up window. This obviously happens when the user clicks a link elsewhere on the page, the change event is triggered when the drop-down list.

Are there any neat solutions to solve this problem? A simple solution would be to trigger an event on the keyboard, but I do not want this function to be executed.

Here is a snippet of a code change event

$('#lookup').change(function()
{
    $.get(..//load template
+3
source share
4 answers

I did not find a solution that I liked or worked purely with my style, so I decided to catch a trigger on the "change" and "keyup" events to avoid this scenario.

0
source

If this is an ajax call, there is a chance that your ajax call will be cached. Make sure you turn off the cache. something like "cache: false"

+1
source

, .

$.get, , , , .

, - (, ).

, , . , , .

0

. , "" , , "lastSelected", , , . , . -, Ajax "lastSelected".

0

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


All Articles