SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2007
    Location
    Ohio, United States
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Event Types Order

    In an ajax chat application I'm writing, a user clicks a button to create a simple text input element. This element has a 'blur' event listener attached to it, so that when the user is finished the content is automatically submitted. I'd like to give my users the ability to click the button that created the text input element to now remove that text input element without submitting it. I added a click event listener to the button that removes the text input element.

    Unfortunately, the content is still submitted. I guess, when the user clicks the button, the blur listener is being executed before the click one. Is there a set order of which event types' listeners are executed? I'm not asking about capturing or bubbling. In this case, the events have different event types.

    In Internet Explorer and Mozilla Firefox, I was able to resolve my problem by using a "mousedown" listener, but in Safari the order the listeners were fired seemed to be in reverse, and so the input was never submitted. I don't think code examples are necessary here, and any I have are too complicated.

    I've scoured the internet in search for some information about the order different event types are fired, but I couldn't find anything. Any help would be greatly appreciated.

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    submitting on blur sounds like a manager's idea.

    the only way to alow another event to precede the blur handler is-
    there isn't one. blurs don't bubble, and can't be cancelled.

    If you are wedded to submit on blur, set a timeout in the blur handler that you can cancel with your remove button click handler.

  3. #3
    SitePoint Member
    Join Date
    Feb 2007
    Location
    Ohio, United States
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mrhoo View Post
    submitting on blur sounds like a manager's idea.

    the only way to alow another event to precede the blur handler is-
    there isn't one. blurs don't bubble, and can't be cancelled.

    If you are wedded to submit on blur, set a timeout in the blur handler that you can cancel with your remove button click handler.
    My goal was to create an effect similar to iTunes playlists. The input field is for a name for a chat room, and the field appears right in line with the rest of the rooms. They can either submit by pressing enter, or on blur.

    Thank you for your help. I'll admit it wasn't the response I had hoped for, but at least it's the truth. I considered the timeout at one point but decided it was way too crude and disgusting. I'll scrap the idea of submitting on blur before I resort to that. Thanks again for your help and honesty.


Bookmarks

Posting Permissions

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