Paul Phoenix
Paul Phoenix

Reputation: 1433

jQuery custom event not firing or triggering

Can anyone tell me what am I doing wrong in the given below code?

<script type="text/javascript">

$('#sp7').on("test", processData);

function processData(e){
recievedData=null;
recievedData[e.message[id]] = e.message;
return recievedData;
}

function testData(id,a){
temp = {id:id, a:a};
$.event.trigger({
type : "test",
message : temp,
time : new Date()
});
}

</script>

I am calling the testData on a button click:

<input type = "button" onclick="testData(1,'a1');" value="test1"/>

Upvotes: 0

Views: 1207

Answers (1)

ffflabs
ffflabs

Reputation: 17481

I don't know if you specifically need to resort to custom events. However, the event should be triggered on the dom element that is supposed to listen to it. Like

$('#sp7').trigger('test',[parameters]);

Upvotes: 2

Related Questions