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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.