How to play a sound when
is updated

Go To


I'm writing a simple chat module that will be embedded in a website. It will allow website visitors to chat with the website owner.

The website is ruby/rails and I'm using AJAX.

One thing I can't figure out how to do is how to play a 'bling' sound when a new message arrives (don't worry, this sound is switchable, and the default is 'off'.)

I want the "bling" to play when the message arrives... i.e., when the div that holds the message list is updated by the Server via Ajax.

I'm thinking I need an Event.observe('myDiv', someEvent, callback) function, but I can't figure out what I should use for 'someEvent'...

Any help, much appreciated.

-- John

2009-06-16 14:18
by John


have you tried 'load' or 'change'? for listeners the event has to be of a certain type described here

another option would be to attach the sound to the AJAX callback function which populates the div.

hope that helps, Josh

2009-06-16 14:33
by Josh