Skip to content

Instantly share code, notes, and snippets.

@lazybean
Created May 22, 2013 15:57
Show Gist options
  • Save lazybean/5628695 to your computer and use it in GitHub Desktop.
Save lazybean/5628695 to your computer and use it in GitHub Desktop.
mojit config is 'lost' after a refreshView. mojito create mojit testConfig then modify the following file. The 'foo' property of the config will be lost when you click on the mojit.
/*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": {
"testConfig": {
"type": "HTMLFrameMojit",
"config": {
"deploy":true,
"child": {
"type": "clickMojit",
"config": {
"foo":42
}
}
}
}
}
},
{
"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