Created
May 22, 2013 15:57
-
-
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.
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
/*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']}); |
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
[ | |
{ | |
"settings": [ "master" ], | |
"appPort": "8666", | |
"specs": { | |
"testConfig": { | |
"type": "HTMLFrameMojit", | |
"config": { | |
"deploy":true, | |
"child": { | |
"type": "clickMojit", | |
"config": { | |
"foo":42 | |
} | |
} | |
} | |
} | |
} | |
}, | |
{ | |
"settings": [ "environment:development" ], | |
"staticHandling": { | |
"forceUpdate": true | |
} | |
} | |
] |
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
/*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']}); | |
~ |
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
[{ | |
"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