Skip to content

Instantly share code, notes, and snippets.

@nuno
Forked from nazrdogan/x.js
Last active June 16, 2016 13:12
Show Gist options
  • Save nuno/a86a646f075feed319a68948b1af0f7c to your computer and use it in GitHub Desktop.
Save nuno/a86a646f075feed319a68948b1af0f7c to your computer and use it in GitHub Desktop.
Events Controllers extend BackBone.Events and as such can dispatch events.
<!--
Events
Controllers extend BackBone.Events and as such can dispatch events.
For example, our index view could also require another controller to deliver the label and listen to an event:
-->
app/views/index.xml
<Alloy>
<Window class="container">
<Require id="label" src="label" onNotify="doSomething" />
</Window>
</Alloy>
<!--
The view of the required label-controller would listen to the click event of the label itself:
-->
app/views/label.xml
*/
<Alloy>
<Label id="label" onClick="passClick">Hello, World</Label>
</Alloy>
<!--
And that label-controller would in turn fire the notify event on itself so the index controller will receive it:
-->
// app/controllers/label.js
function passClick(e) {
$.trigger('notify');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment