Created
April 8, 2014 23:59
-
-
Save thehydroimpulse/10210946 to your computer and use it in GitHub Desktop.
This file contains 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
// actionbutton/index.js | |
var template = require('./template.html'); | |
var View = require('view'); | |
var NextView = require('next-view'); | |
var SpinnerAnimation = require('spinner-animation'); | |
var resource = require('resource'); | |
var animation = require('animation'); | |
var ActionButton = View.create() | |
.use(View.compiler(template)) | |
.use(animation()) | |
.scope(function(scope) { | |
scope.records = []; | |
}); | |
// Button is pressed. | |
ActionButton.prototype.click = function(event) { | |
var self = this; | |
// Initialize a new animation: | |
this.animation('loading', new Spinner()).begin(); | |
// Load a resource (ajax) | |
resource('name').all(function(err, records) { | |
// Stop the animation: | |
self.animation('loading').stop(); | |
// Update the scope: | |
self.scope.swap('records', records); | |
// Mount the next component. | |
self.component('next', new NextView()).mount(); | |
}); | |
}; |
This file contains 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
// actionbutton/template.html | |
<button class="ui button" data-click="click"> | |
ActionButton | |
</button> | |
<span data-animation="loading"></span> | |
<span data-component="next"></span> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment