backbone.js - Combining UNDERSCORE.JS and JSP -
i'm trying develop web application obtains information server (in mysql database ) , shown client (via browser) information.
i want use backbone.js , default templates system (underscore.js) in client part. other hand, want use jsp accessing information mysql database in server.
my problem don't know fine if it's possible combine jsp , underscore.js (independently of syntax's problems associated fact <% %> structure same both technologies of).
i have searched it, haven't found example use both technologies.
it's possible combine both? or why not? can show me example?
thanks in advance!!
modified next:
i'm aware of syntax problem's existence, don't understand combine both (jsp , undescore.js). if have next template (underscore.js) in html file:
<!-- language: lang-js --> <script type="text/template" id="showtemplate"> <h2> <%= title %> <small>by: <%= author %></small> </h2> <p style="white-space:pre-wrap;"><%= description %></p> </script>
and have backbone's view replace 'title', 'author' , 'description' fields of template corresponding values:
<!-- language: lang-js --> viewexample = backbone.view.extend({ // constructor initialize: function (options) { this.note = options.note; }, // populate html dom render: function () { this.$el.html(_.template($('#formtemplate').html(), {title: "environment", author:"albert", description:"textdescription"})); return this; } });
how can getting value of 'title', 'author' , 'description' fields obtained server via jsp?
here new _.temeplatesettings backbone.js
_.templatesettings = { interpolate: /\{\{(.+?)\}\}/gim, evaluate: /\{\{(.+?)\}\}/gim, escape: /\{\{\-(.+?)\}\}/gim };
template syntax:
<script type="text/template" id="item-template"> <div class="view"> <input class="toggle" type="checkbox" {{ done ? 'checked="checked"' : '' }} /> <label>{{ title }}</label> <a class="destroy"></a> </div> <input class="edit" type="text" value="{{ title }}" /> </script>
Comments
Post a Comment