Bind function's variable

edited December 2016 in Newbie Questions
hello
in my code :
<br />var<br />    kind = require('enyo/kind'),<br />    Button= require('enyo/Button'),<br />    Input=require('moonstone/Input'),<br />    Image=require('enyo/Image');<br />    var  BodyText = require('moonstone/BodyText'),<br />    Component = require('enyo/Component');<br /><br />input2=kind({<br />    name : 'MediaItem',<br />    kind : Button,<br />    classes : 'repeater-item class1 item',<br />    style : "width:150px;height:100px;margin-bottom:250px;",<br />    published : {<br />        mediaImgUrl : ''<br />    },<br />    create : function(){<br />        this.inherited(arguments);<br />        this.colorChanged();<br />    },<br />    components : [<br />        { kind: Image, name: 'title'},<br />        { kind:BodyText, name: 'thumbnail',content:'heloooooo'}<br />    ],<br />    bindings: [<br />        {from: 'mediaImgUrl', to: '$.thumbnail.content'},<br />//        console.log("bining in top")<br />    ],<br />    handlers: { <br />        ontap: 'goToShow'<br />    },<br />    goToShow : function(sender, ev){<br />        this.log("Sender: "+sender.name);<br />        element='';<br />    },<br />   <br />});<br /><br /><br /><br />module.exports = kind({<br />	 name: "MediaItemSample",<br />	    components: [<br />	        {kind: input2},<br />	        {kind:Input, name: 'inputImageSrc',value:'zahra',  placeholder: 'Thumbnail URL'},<br />	       <br />	    ],<br />	    Show : function(sender, ev){<br />	    	myVar='hhhh'<br />//	        this.log("Sender: "+sender.name);<br />	    },<br />	    bindings: [<br />	        {from: '$.inputImageSrc.value', to: '$.mediaItem.mediaImgUrl', oneWay: false},<br />//	        console.log("bottom biiindiiing ")<br />	    ]<br />}); 
i want to bind value of myVar from a "Show" function to element of goToShow function .
how can i do that ?

Comments

  • Not understanding exactly what you want to accomplish here. You can't bind variables and you can't bind to functions (like that). You don't have a name on your input2 kind in MediaItemSample. But, what you probably want to do is, in the Show method, is call the set() method on the input2's mediaImgUrl property.
Sign In or Register to comment.