N
N
Nathan Stark2016-04-17 09:59:30
JavaScript
Nathan Stark, 2016-04-17 09:59:30

How to popup a modal window if no match is found in autocomplete?

Good to everyone!
The task is this: there is an input field in which the uikit "autocomplete" component is used, it is necessary during the loss of focus if autocomplete did not find a match, display a modal window (which will offer to add data).
The problem actually is to display the modal only under this condition. I wanted to use 2 events
1. on("focusout" to catch the loss of focus
2. on('selectitem.uk.autocomplete' the component event fires if autocomplete in the field was used from the list.
The idea was that if the second event worked, then 1 do not use ... but it turns out that first it processes 1 event and only then 2.
It turned out to make such a crutch:

$('#UACProject').on('selectitem.uk.autocomplete', function(){
        modal.hide();
    });

    $('#UACProject').on("focusout",".StartInpAjaxProject",function(){
        modal.show();
    });

those. first shown then hidden. In general, it works, but it's a crutch ... I want a more elegant solution to the problem, so to speak, for my own development.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question