-
-
Save nuno/a86a646f075feed319a68948b1af0f7c to your computer and use it in GitHub Desktop.
Events Controllers extend BackBone.Events and as such can dispatch events.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
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: | |
--> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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