?
Solved

never stops alert

Posted on 2014-12-12
15
Medium Priority
?
95 Views
Last Modified: 2014-12-12
<script>

$("input").blur(
             function (event) {
                 alert("test");
             }
         );

</script>

I am using this script in a jquery mobile page, when i leave an input box, this never stops sending the alert message, any idea?
0
Comment
Question by:joyacv2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 2
  • +1
15 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40496819
I'm guessing the alert is causing focus to be lost and then focus is changed again or something along those lines
Do you have some real code to look at?
0
 
LVL 9

Expert Comment

by:WebDevEM
ID: 40496833
Hi,

I set up a Fiddle (http://jsfiddle.net/webdevem/43j66esh/) to test this - At first I thought it was going to trigger because "input" would attach to all inputs on the page and no matter where the page focus is, it would be blurred from another input.

Odd thing is, it only triggered once for me.  What browser/version were you using?  This worked fine for me in Chrome for Mac
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40496834
ok,

is a bunch of code that works with php, and for testing needs to many configuration files, do you know any alternative to blur in this case?
0
Python: Series & Data Frames With Pandas

Learn the basics of Python’s pandas library of series & data frames and how we can use these tools for data manipulation.

 
LVL 1

Author Comment

by:joyacv2
ID: 40496840
i am using safari for mac
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40496845
i want to when the user leaves an input, an ajax is called, but i never passed the alert test that i always do before continue
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40496847
in chrome works well, but in safari never stops
0
 
LVL 58

Expert Comment

by:Gary
ID: 40496867
Do you have a test page to look at?
When you leave the input is it go to another input?
What is the purpose of the alert - do you really need it or is it just for testing?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40496876
Must be a Safari bug, happens for me too,
0
 
LVL 58

Expert Comment

by:Gary
ID: 40496883
Yep it's a bug in Safari
Possible solution is to unbind the event before the alert and then rebind it after the alert.
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40496888
Hi Gary,

The test on the WebDevEM is perfect for the discussion. This is exactly what is happening to me. Let me try to explain my purpose,

I want to update a database after an user leaves an input using ajax, so i found that blur will give me the method for run the code after the user leaves the input, do you know any other solution?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40496905
The blur is fine but remove the alert so you don't end up in circles with a focus/blur firing.
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40496910
yes, but this will cause that my code repeat forever to the database
0
 
LVL 9

Expert Comment

by:WebDevEM
ID: 40496922
I think I see Gary's point... the alert itself may be changing the focus.  Try removing it or replacing it with something like changing the background color of something, or appending text to another element so you know its there.

I'll update the Fiddle with an example
0
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40496924
No, it's the alert itself which is causing the multiple alerts, once you remove that then it will only fire once.

And forget http:#a40496883 - just tested and it still keeps firing.
0
 
LVL 58

Expert Comment

by:HainKurt
ID: 40496926
dont use alert in blur... do whatever you need here but just dont use alert :)

or use something like this...

$("#msg").htlm("message here...");
0

Featured Post

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question