views:

118

answers:

1

I have 2 divs that each have clicks bound to them. when you click on a div a form is displayed (in another div) that allows you to set properties specific to the div that is clicked.

I'm using focusout to save the properties to a data object. everything is working perfectly except when i click on the other div. it seems that the click handler on the other div cancels out the focusout of the form field.

Has anyone else experienced this? is so what is the proper way to overcome this?

A: 

You should try binding both events within a single function like:

$('div').bind('focusout click', function(e){
  if (e.type=='click'){
    //what's inside your .click(function(){ ... })
  }
  else {
    //as long as this's triggered only on click and focusout the following lines will be executed on focusout only
  }
});

never tried before, should prevent canceling if that's the reason it doesn't work

Zlatev