Custom events could help:

// use custom event as a proxy
$(someInput).observe('change', function()
{ this.fire('content:changed') });
...
doIncrement : function() {
   this.inputBox.setValue((parseFloat($F(this.inputBox)) +
0.1).toFixed(1));
   // fire custom event
   this.inputBox.fire('content:changed');
   this.timeoutEvent = setTimeout( this.doIncrement.bind(this), 150 );
},
...
// observe custom "content:changed" instead of "change"
$(somInput).observe('content:changed', function(e) {
  // do stuff
})

You could also take a look at Event#simulate
http://github.com/kangax/protolicious/tree/master/event.simulate.js

- kangax

On Jun 17, 8:33 pm, Dean <[EMAIL PROTECTED]> wrote:
> Hi Prototype people
>
> Is there a good way to fire the browser's native onchange event?
> Here's my situation.
>
> I am using prototype and lowpro.  I have a text input box and some
> divs.  When the user mousedown's on one div, numbers in the input box
> start changing.  onmouseup, the numbers stop changing.  I would also
> like to alert the form that one of its inputs has changed.
>
> Here are some simplified snippets of the lowpro Behavior class I
> created to do the heavy lifting:
>
> doIncrement : function()
> {  newVal = 1 * this.inputBox.value;
>    newVal = newVal + 0.1;
>    newVal = newVal.toFixed(1);
>    this.inputBox.value = newVal;
>    this.timeoutEvent = setTimeout( this.doIncrement.bind(this), 150 );
>
> },
>
> onmousedown : function(evt)
> {  this.doIncrement();
>
> },
>
> onmouseup : function(evt)
> {  clearTimeout( this.timeoutEvent );
>    this.inputBox.focus();
>
> }
>
> Since I explicitly set the input's value with this.input.value =
> newVal; the onchange event does not trigger (in Firefox 2.0.0.12 for
> linux).
>
> I am sprinkling these input into different forms that I need to inform
> of changes, so calling a custom function in onmouseup() won't do the
> trick.
>
> It appears that jQuery can do it, and from what I gather in its
> source, they eventually just do elem["change"](); but that throws an
> "is not defined" error.
>
> Any suggestions?
>
> Regards,
> --Dean
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to