Closed bartonhammond closed 9 years ago
So I made a small but significant change after thinking about how I should approach this.
First look at http://webix-components.meteor.com/ so you can see the Webix button I'm exposing via the BlazeComponent.
So now I have a different view presented and have access to the original helpers via the Mixin.
But I'm currently not accessing the "text" value via the Mixin as you can see below.
var text = Blaze._getTemplateHelper(Template.atNavButton, 'text', Template.instance)();
So the template is now:
<template name="atNavButton">
<div id="atNavButton"></div>
</template>
How do I use the Mixin "text" value instead? The BlazeComponent atNavButton.js would be changed in the "onRendered" function.
// Simply 'inherites' helpers from AccountsTemplates
Template.atNavButton.helpers(AccountsTemplates.atNavButtonHelpers);
// Simply 'inherites' events from AccountsTemplates
Template.atNavButton.events(AccountsTemplates.atNavButtonEvents);
var atNavButton = BlazeComponent.extendComponent({
template: function () {
return 'atNavButton';
},
onRendered: function() {
debugger;
//This works but I'd rather use the Mixin
var text = Blaze._getTemplateHelper(Template.atNavButton, 'text', Template.instance)();
webix.ui({
view:"button", label:text , width: 100
}, $$('atNavButton'));
},
mixins: function () {
return [ExposeTemplateHelpersMixin];
},
/*
text: function() {
debugger;
return Blaze._getTemplateHelper(Template.atNavButton, 'text', Template.instance)();
},
*/
events: function () {
return [{
'click *': this.onClick
}];
},
onClick: function (event) {
console.log('WebixNavButton.onclick');
}
}).register('atNavButton');
Ah, so easy, it's
this.text()
most Excellent!
The ExposeTemplateHelpersMixin appear to be working. You can see http://webix-components.meteor.com/ that the BlazeComponent correctly displays the value from the base Helper.
Now I want to override that helper function in my BlazeComponent so that I can "onRendered" provide a new & different view.
The template I am inheriting is atNavButton which has the {{text}} property
How do I make my BlazeComponent WebixNavButton.js override the "text" property of the mixin so I can use it in the new "Webix" view? I tried defining the "text" function but it was never called.
I was hoping I could do something like the following, in that I could retrieve the value and do what I want.
Thanks for your help