I must be missing something basic here but while developing a custom jQuery widget, how do we include a html template as part of the widget like we do with dojo custom widgets? Currently, my jQuery custom widget is generating the needed html in JavaScript and I am trying to take that out into a html template and include it with the custom widget. Thoughts?
I must be missing something basic here but while developing a custom jQuery widget,
Share
You can have a look at Handlebars.js. THis is a jQuery template plugin and The syntax is pretty easy
Declare a Templae with
scripttagThen fetch and compile that template like this
Then you can render that template by passing data for
palceholderslike thisAfter this you will have the ful
htmlinhtmlvariable which you can use in any jQuery DOM manipulation method like$.append.Working Fiddle