Skip to content

Instantly share code, notes, and snippets.

@caridy
Forked from lazybean/controller.server.js
Last active December 17, 2015 14:59
Show Gist options
  • Save caridy/5628753 to your computer and use it in GitHub Desktop.
Save caridy/5628753 to your computer and use it in GitHub Desktop.
/*jslint anon:true, sloppy:true, nomen:true*/
YUI.add('clickMojit', function(Y, NAME) {
/**
* The clickMojit module.
*
* @module clickMojit
*/
/**
* Constructor for the Controller class.
*
* @class Controller
* @constructor
*/
Y.namespace('mojito.controllers')[NAME] = {
/**
* Method corresponding to the 'index' action.
*
* @param ac {Object} The ActionContext that provides access
* to the Mojito API.
*/
index: function(ac) {
Y.log('config: '+ Y.JSON.stringify(ac.config.get()), 'WARN', NAME); //will change when refreshView
ac.models.get('clickMojitModelFoo').getData(function(err, data) {
if (err) {
ac.error(err);
return;
}
ac.assets.addCss('./index.css');
ac.done({
status: 'Mojito is working.',
data: data
});
});
}
};
}, '0.0.1', {requires: ['mojito', 'mojito-config-addon', 'mojito-assets-addon', 'mojito-models-addon', 'clickMojitModelFoo']});
[
{
"settings": [ "master" ],
"appPort": "8666",
"specs": {
"testchild": {
"type": "clickMojit",
"config": {
"foo":42
}
},
"testConfig": {
"type": "HTMLFrameMojit",
"config": {
"deploy":true,
"child": {
"base": "testchild"
}
}
}
}
},
{
"settings": [ "environment:development" ],
"staticHandling": {
"forceUpdate": true
}
}
]
/*jslint anon:true, sloppy:true, nomen:true*/
YUI.add('clickMojitBinderIndex', function(Y, NAME) {
Y.namespace('mojito.binders')[NAME] = {
init: function(mojitProxy) {
this.mojitProxy = mojitProxy;
},
bind: function(node) {
var me = this;
this.node = node;
this.clickHandler = node.on('click', function(e) {
this.mojitProxy.refreshView();
}, this);
},
onRefreshView: function(node) {
this.clickHandler.detach();
this.bind(node);
}
};
}, '0.0.1', {requires: ['event-mouseenter', 'mojito-client']});
~
[{
"settings": [ "master" ],
"frame": {
"path": "/",
"verb": ["GET"],
"call": "testConfig.index"
}
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment