Forum: Rails Spinoffs (closed, excessive spam) Correct way of setting click events for input buttons

Posted by AntonioCS (Guest)
on 2008-06-19 20:12
(Received via mailing list)
Hey I have a form in my html body and I am trying to set an onclick
event for a button.

I have this code:

var acs_ref = Class.create({
     initialize: function() {


Event.observe('ref_del_id','click',this.remover_url.bindAsEventListener(this));

  },
  remover_url:function() {
    alert("Teste");
  }
});
new acs_ref();

When I run this code I get a prototype error

element is null
[Break on this error] if (element._prototypeEventID) return
element._prototypeEventID[0];

This must be something related to it being a form element but I really
don't know how to set events for the buttons I normally use links but
this time I have to use button forms.
Anyone know the correct way to set up this?
Thanks
Posted by Diodeus (Guest)
on 2008-06-19 20:17
(Received via mailing list)
$('DIVNAME').observe('click', function(){alert("HELLO")});

Just make sure you create the event AFTER the page has loaded.
Posted by AntonioCS (Guest)
on 2008-06-20 00:47
(Received via mailing list)
Thanks :D

I was making that mistake lol
This topic is locked and can not be replied to.