Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple event invocation onblur and onclick

    Hi,

    I have a problem in javascript, where entering a value in the textbox during onblur I am doing a refresh to bring in the
    updated records from the DB , before the on blur refresh is completed if the user clicks the search button (onclick)
    during the first click nothing is happening as the refresh is still going on. During the second click when the on blur refresh
    is completed it will open a popup.

    The problem here is I am unable to disable/inactivate the search button untill the refresh is completed as well as I dont have any control over the
    refresh time as well. This is like already an event is in progress and where we are invoking another event which is not having
    any effect. In such case how i can handle this scenario?

    Thanks.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    If you use event listeners instead of event handlers then you will be able to detach events when you don't want them to run and reattach them when you do.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Why are you doing a page reload on blur? Why not just use AJAX?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    Quote Originally Posted by glenngv View Post
    Why not just use AJAX?
    The op might be coding the functionality for when javascript is turned off or not available on the user's device.

  • #5
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Guys. I am doing an AJAX call on on blur , please provide some example on the same using event listeners as supposed to event handlers.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by contactanantha View Post
    Thanks Guys. I am doing an AJAX call on on blur , please provide some example on the same using event listeners as supposed to event handlers.
    Then disable the Search button by default and then when the AJAX response is available, enable it. If you are using jQuery ajax, you enable the button in the 'complete' callback. If you are just using plain AJAX, you enable the button when xmlhttpObj.readyState == 4.
    Last edited by glenngv; 03-15-2012 at 11:07 AM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks. That is the easier option but that is not accepted by the client. Hence is there other way around it. Please explain. This is pretty urgent. Thanks.

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    I'm wondering why the client doesn't accept that solution.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #9
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    Quote Originally Posted by contactanantha View Post
    .....This is pretty urgent......
    It's just about 9 hrs since your last post.

    When do you need it by?

  • #10
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Guys, I am trying this pretty hard with little luck any help is highly appreciated.
    Hope I get a better luck this time and BTW this is my first post in this forum. Please provide a helping hand. Thanks.

  • #11
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Any solution for this?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •