Skip to content

Commit

Permalink
Fixed #32
Browse files Browse the repository at this point in the history
  • Loading branch information
jacomyal committed Jun 12, 2013
1 parent 2a96091 commit e09a622
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/domino.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,7 @@
});

scope.dispatchEvent = function(type, data) {
this._events.push({
type: type,
data: data
});
this._events.push(_self.getEvent(type, data));

return this;
};
Expand Down Expand Up @@ -796,7 +793,7 @@
a = _utils.array(obj['events']);
for (k in a) {
reiterate = true;
dispatch[a[k].type] = 1;
dispatch[a[k].type] = a[k];
}

for (k in obj['update'])
Expand All @@ -820,8 +817,14 @@

// Check events to dispatch:
events = [];
for (event in dispatch)
events.push(_self.getEvent(event));
console.log(dispatch);
for (event in dispatch) {
events.push(
dispatch[event] === 1 ?
_self.getEvent(event) :
dispatch[event]
);
}

// Start looping:
if (reiterate)
Expand Down
16 changes: 16 additions & 0 deletions test/unit.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ asyncTest('Services', function() {
this.prop_8 = 'def';
}
}
},
{
data: 'abc',
expected: 'def',
label: 'Dispatch an event with data',
params: {
type: 'POST',
contentType: 'application/json',
data: { value: 'def' },
success: function(data) {
this.dispatchEvent('update_prop_9', {
prop_9: data.prop_9
});
}
}
}
];

Expand All @@ -167,6 +182,7 @@ asyncTest('Services', function() {
return {
id: 'prop_' + i,
dispatch: 'prop_' + i + '_updated',
triggers: 'update_prop_' + i,
type: '?*'
};
}),
Expand Down

0 comments on commit e09a622

Please sign in to comment.