I am calling a service that returns json data.
script:
$.ajax({
type: "POST",
url: "/some/service",
dataType: "json",
success: function(response) {
if (response.status == "ok" && response.messages.length > 0) {
obj.trigger(SOME_EVENT, response.messages);
}
}
});
this is an example response:
{
"status":"ok",
"messages":[
{"id":1,"message_text":"latihan"},
{"id":123,"message_text":"hello"}]
}
when obj received the SOME_EVENT trigger, I expect it to pass the message data below:
[{"id":1,"message_text":"latihan"},
{"id":123,"message_text":"hello"}]
but when I printed the message options for the console,
obj.bind(SOME_EVENT, function(sender, messages) {
console.log(messages);
});
he just relayed the last message below
{"id":123,"message_text":"hello"}
can anyone explain why the message array is not passed by my custom event?