jquery-templates

Building HTML with templates versus building it in javascript?

限于喜欢 提交于 2019-12-22 06:17:38
问题 I recently started making web apps, and while I make some stuff that works, I'm not sure of the best practices. Up to now, I've mostly used the templating systems of Django, web.py and PHP. But now that I'm using jQuery and nice ajaxy magic to get data from the server without refreshing the client, I'm seeing the advantages of building the HTML directly in javascript (so I can just send a small json object to the client and have him figure out what to change and how). So now I have some bits

Where to keep html templates?

。_饼干妹妹 提交于 2019-12-22 04:05:31
问题 I have a single page app. Currently my templates stored in index.html e.g. <script id="button" type="text/html"> <a class="button" href="#" id="${id}"> ${value} </a> </script> Is it a best practice to store them in such way? I've found jQuery templates - where should I put them? but there is no acceptable answer. 回答1: You are doing it right. There is no need to add unnecessary complexity to a single-page app, according to the KISS principle: Most systems work best if they are kept simple

jquery mobile does not render list after jquery template was inserted

ぐ巨炮叔叔 提交于 2019-12-21 21:59:37
问题 I am adding tags using jquery templates to jquery Mobile website. It adds li tags, however it does not style in the standard jqueryMobile style. I can see it visually and by inspecting DOM: jquery mobile adds classes and convert to div and span classes, where in my case I see plane ul and li tags without any jquery mobile classes. I have a version, that it loads first Jquery Mobile, and then injects jquery template and Mobile does not refresh that list and doesnt style it. Is there a way to

Controlling Flash Plugins with Knockout.js, Conflicting jQuery.tmpl and Knockout-Sortable

谁说我不能喝 提交于 2019-12-20 03:00:56
问题 I'm trying to render HTML for embedding Flash objects using Knockout.js' native templating faculties. jQuery.tmpl does the job perfectly well, however I cannot use it due to conflicts with the Knockout-sortable plugin. Here's an example of flash plugins quirking with the native templating: http://jsfiddle.net/7y3ub/35/ In Chrome, the player just never shows up. In Firefox, the player will show up if you change the channel while the checkbox is checked. Rechecking the box however makes the

How do I format Date/Time with jQuery Templates?

倾然丶 夕夏残阳落幕 提交于 2019-12-18 19:32:13
问题 i've just started using jQuery Templates as my javascript template engine. My question is, how can i format a date (returned from a ASP.NET Json ActionResult) in the form: /Date(1288709830000)/ I tried doing the following: {{= $.format(new Date(parseInt(comment.DateCreated.substr(6))), 'd')}} Note the above uses the new jquery globalization plugin to add the $.format method. Also note that {{= comment.DateCreated }} is long hand for saying ${comment.DateCreated} . I'd really appreciate it if

How do I format Date/Time with jQuery Templates?

时间秒杀一切 提交于 2019-12-18 19:32:09
问题 i've just started using jQuery Templates as my javascript template engine. My question is, how can i format a date (returned from a ASP.NET Json ActionResult) in the form: /Date(1288709830000)/ I tried doing the following: {{= $.format(new Date(parseInt(comment.DateCreated.substr(6))), 'd')}} Note the above uses the new jquery globalization plugin to add the $.format method. Also note that {{= comment.DateCreated }} is long hand for saying ${comment.DateCreated} . I'd really appreciate it if

Best way to populate select list with JQuery / Json?

只愿长相守 提交于 2019-12-17 16:50:13
问题 Currently our dev team uses this pattern, but I can't help but wonder if there is a faster or more html-efficient way of accomplishing the same task. HTML <select id="myList" style="width: 400px;"> </select> <script id="myListTemplate" type="text/x-jQuery-tmpl"> <option value="${idField}">${name}</option> </script> And this is the Javascript: function bindList(url) { callAjax(url, null, false, function (json) { $('#myList').children().remove(); $('#myListTemplate').tmpl(json.d).appendTo('

jQuery Templating - Associating data to template DOM elements

非 Y 不嫁゛ 提交于 2019-12-14 00:55:58
问题 I am using jQuery's template plugin rendering several row items similiar to this: var clientData = [ { name: "Rey Bango", id: 1 }, { name: "Mark Goldberg", id: 2 }, { name: "Jen Statford", id: 3 } ]; <script id="clientTemplate" type="text/html"> <li><${name}</li> </script> $("#clientTemplate").tmpl(clientData).appendTo( "ul" ); I am wondering if it is possible to make use of jQuery's data function to be able to associate each row item back to an identifier for updating. Normally you could do

How To Cache jQuery Template In Backbone View via Ajax?

守給你的承諾、 提交于 2019-12-13 08:12:44
问题 I am using backbone.js and jQuery templates. What I'd like to do is set the view's template to a dom element. It looks something like this: <script id="templateElement" type="text/x-jQuery-tmpl"> <div class='foo'>bar</div> </script> When the view is initialized, it will see if the template exists with $.isFunction. If it doesn't it will get it from an external file and append the returned dom element to the body element and then set this.template to that dom element. The next time the view is

custom variables in FOR with JsRender

心不动则不痛 提交于 2019-12-13 06:02:04
问题 I'm migrating from jQuery templates to JsRender and I don't know how to fully translate an {{each}} into a {{for}} With jQuery templates I could do something like this: {{each (i, val) object.items}} <span data-index="${i}">${val}</span> {{/each}} Where object.items is an array of values and I could define a custom index and item variables to show data (in this case i and val ). But how do I do the same thing in JsRender? {{for object.items}} <span data-index="{{:#index}}">{{:#data}}</span> {