Jump to content

If I don't Click?


unemployment

Recommended Posts

can you explain a little more in depth what is it that you are trying to do?

 

I have an autosuggest drop down and when I click it, my onblur from my input field remove my autosuggest box with...

 

search_field.onblur = function()

{

general_search.hide();

}

 

But if I click a suggested item in the drop down I don't want the onblur to be executed.

 

Any idea how to do this?

Link to comment
https://forums.phpfreaks.com/topic/238336-if-i-dont-click/#findComment-1224828
Share on other sites

Judging by the hide() call I'm guessing you're using jQuery? Hopefully so, as the has() method makes this real easy. Give this a try:

 

search_field.onblur = function()
{
    var curr_target = null;
    var autosuggest = $('#id_of_autosuggest_box');

    if (event.toElement) {
        curr_target = event.toElement;
    } else if (event.relatedTarget) {
        curr_target = event.relatedTarget;
    }

    if ($(this).has(curr_target).length == 0
     && autosuggest.has(curr_target).length == 0) {
        general_search.hide();
    }
}

 

Make sure you change the ID.

Link to comment
https://forums.phpfreaks.com/topic/238336-if-i-dont-click/#findComment-1225165
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.