Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery- focusout only when another element not clicked

When the user focuses on a certain element, I display a save button. On focusout, I remove the save button.

alt text

The user can submit the input by either hitting return or click save. When they click the save button, the input loses focus and the save button is removed, thus not registering the click. Can I tell in the focusout, if the save button has been clicked?

Within my focus function I do something like this:

        $('#save_button').click(function(){
            saveEditingField(this); //save input
            $('#save_button').die("click");
        });

        $('.editing').focusout( function(e) {
            $('#isediting').attr('value','false');
            $('#edit_controls').remove()
        });

I've tried adding a delay to the remove(), but when tabbing between inputs it shows multiple save buttons (while the others are being removed).

Any ideas?

like image 298
christo16 Avatar asked Dec 13 '22 18:12

christo16


1 Answers

I think you only need a little timeout between focusout and removing/hiding the button.

like image 184
Dr.Molle Avatar answered Jan 06 '23 13:01

Dr.Molle