Is it possible, to generate an event on a text field?

Discussion in 'Javascript' started by stephen.cunliffe@gmail.com, Jan 18, 2007.

  1. Guest

    Situation:

    I have a few event handlers (not onclick) on a text box. The handlers
    take in an event parameter to work some magic.

    All the above works fine, but I have a desire/need, to "invoke" the
    same handlers, but from another element (e.g. a separate button)

    I know that someObject.click(); will actually work, but in my case, I
    do not want to invoke the onclick handler.

    Any Ideas?

    PS I'd be happy to "fake" any of the following...

    ondblclick
    onkeydown
    onkeyup
    onkeypress

    Cheers,
    Steve
     
    , Jan 18, 2007
    #1
    1. Advertising

  2. Craig Taylor Guest

    wrote:
    > Situation:
    >
    > I have a few event handlers (not onclick) on a text box. The handlers
    > take in an event parameter to work some magic.
    >
    > All the above works fine, but I have a desire/need, to "invoke" the
    > same handlers, but from another element (e.g. a separate button)
    >
    > I know that someObject.click(); will actually work, but in my case, I
    > do not want to invoke the onclick handler.
    >
    > Any Ideas?
    >
    > PS I'd be happy to "fake" any of the following...
    >
    > ondblclick
    > onkeydown
    > onkeyup
    > onkeypress
    >
    > Cheers,
    > Steve


    Instead of 'faking' an event have you consdered doing the following:

    in regular event handler call common_function()

    and then call common_function()ality from both your event handler and
    the other places that you need that behavior.

    To answer your original question: In javascript inheritance is done by
    making an object that looks like the original so you can always define
    your own "event" with the properties that are referenced and then call
    the events directly.

    If you really want to go through the formal creation of an event object
    then take a look at document.createEvent / document.createEventObject /
    target.dispatchEvent / target.fireEvent.

    - Craig Taylor
    www.ctalkobt.net
     
    Craig Taylor, Jan 18, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerry Manner
    Replies:
    5
    Views:
    561
    Jonathan N. Little
    Jun 9, 2005
  2. ehm
    Replies:
    2
    Views:
    206
  3. Sound
    Replies:
    2
    Views:
    454
    Randy Webb
    Sep 28, 2006
  4. kerinin
    Replies:
    8
    Views:
    216
  5. jr
    Replies:
    3
    Views:
    429
Loading...

Share This Page