Planning to use view helpers in my JMVC application. Tried to implement select_tag helper function in my ejs file but failed to obtain required results. Below is the code
In Controller :
this.choice= [{value: 1, text: 'First Choice'},
{value: 2, text: 'Second Choice'} ];
this.element.html(initView({choice:this.choice}));
In Ejs file :
<%= select_tag('elementId', 1, this.choice) %>
Reference https://code.google.com/p/embeddedjavascript/wiki/ViewHelpers
Do we need to steal any packages ? is there any sample code ?
To get access to the helpers I did three things...
I updated the first line of file jquerypp/view/helpers/helpers.js from:
steal('jquerypp/view/ejs').then(function($){
to
steal('jquerypp/view/ejs').then(function(){
I stole 'jquerypp/view/helpers' in the controller.
Finally, in the ejs instead of
<%= select_tag('elementId', 1, this.choice) %>
I used
<%== select_tag('elementId', 1, this.choice) %>
to force ejs to render the select block as part of the page instead of rendering an escaped quoted version.