Dynamic binding?

edited October 2013 in Enyo 2.4
In the MVC Bootplate app, binding is defined like this:
bindings: [{
 from: ".app.controllers.message.data",
 to: ".$.input.value",
 kind: "enyo.InputBinding"
Where ".app..." refers to a data store in the app, and the ".$input.value" refers to an input control {name:'input'}.

If I dynamically create a component, can I still bind this way? I tried a few things like variations of this code:
this.bindings.push(this.createComponent({ kind: "enyo.InputBinding"
 , from: ".$.username.value"
 , to: ".mvcApp.data.username"
 , owner: this}));
But haven't been able to get this to work.

I do have this working, but I'm not sure it's ideal.
bindInputData: function(bindOwner) {
  bindOwner.setData = function (inSender, inEvent) {
    mvcApp.data[inSender.name] = this.value;
    return true;
This raises a semi-related question: Is there a generic way to refer to the top level of the application? Since I initialize my app with a name
new Bootplate.MvcApp({name: "mvcApp"});
if I have to refer to the top level I need to name it explicitly: mvcApp.waterfall(), mvcApp.getSomeData(), etc. Is there a clean way to reference the Application top level container without hardcoding the name of the app itself?


  • Forgot to show how I use my bind method:
    this.createComponent( { name: "inputText",
     kind: "onyx.Input",
     placeholder: "Input Text",
     owner: this
  • The ".app" in the biding is actually a reference to a local .app reference that is added to all the kind instances by the ApplicationSupportMixin. It points back to the application object that owns your app, not a global "app" variable.

    The ".$" refers to the hash of components stored in the kind instance. Since you create your component with the name "inputText", using ".$.inputText" should work to refer to that components properties.
Sign In or Register to comment.