jquery-templates

Using custom type attribute in <script> tags such as jQuery's text/x-jquery-tmpl

只愿长相守 提交于 2019-11-30 04:59:26
I noticed that jquery's beta template plugin is using, the type attribute "text/x-jquery-tmpl" e.g <script type="text/x-jquery-tmpl"> I've not seen custom use of the type attribute in the past. Has anyone seen current examples of this in use or perhaps ways mere mortal developers such as I can use this in our own code? I presume that it's sort of a MIME type, however I would of thought that MIME type support was up to the browser. So I would of assumed that custom MIME types would be unsupported? The type actually does indicate what sort of script is there. If the browser doesn't understand it

Show progress bar while knockout is rendering the view

拟墨画扇 提交于 2019-11-29 20:33:30
问题 I have a complex page that uses knockout to render the contents via templates. It takes around 10 seconds to render so I want to show a progress bar while this happens. I have tried to add a callback in the template to the afterRender method which broke the page - I think this method is more to do with fiddling with the html generated by the template. I have also tried creating a binding handler that updates the progress bar on every call: ko.bindingHandlers.updateProgressBar = { init:

How do I render a jQuery.tmpl Template to a String?

倾然丶 夕夏残阳落幕 提交于 2019-11-29 12:01:56
问题 The documentation for jquery.tmpl uses .appendTo to insert the template into the DOM during the rendering process: $.tmpl( myTemplate, myData ).appendTo( "#target" ); I am attempting to convert an existing app from another templating engine, and my code needs to render a template into a string first before it is added to the DOM. Is this possible? How would that be done? 回答1: jQuery Templating provides $.template() (see description in source code) - it returns array of strings after

<script> tag inside jquery template

两盒软妹~` 提交于 2019-11-29 09:07:30
Backgroud: I have this template that includes videos from youtube being loaded with swfobject. Question: Is there a way to include a script tag... <script type="text/javascript"> </script> inside a jQuery Template?? <script id="filaVideoTemplate" type="text/x-jQuery-tmpl"> <!-- Some HTML here --> <script type="text/javascript"> <!-- Some javascript here --> </script> </script> Obviously it doesn't work directly, is there any way to achive the same thing without the script inside other script? <script id="filaVideoTemplate" type="text/x-jQuery-tmpl"> <!-- Some HTML here --> <script type="text

Knockout.js Templates Foreach - force complete re-render

萝らか妹 提交于 2019-11-29 07:15:29
By default, KO "will only render the template for the new item and will insert it into the existing DOM". Is there a way to disable this feature (as in, force KO to render all items anew)? If you use jQuery.tmpl's native {{each koObservableArray()}} syntax Knockout cant update single items but must rerender the entire template see more here: http://knockoutjs.com/documentation/template-binding.html the template engine’s native ‘each’ support: after any change, the template engine is forced to re-render everything because it isn’t aware of KO’s dependency tracking mechanism. You only get the

Using custom type attribute in <script> tags such as jQuery's text/x-jquery-tmpl

…衆ロ難τιáo~ 提交于 2019-11-29 02:32:35
问题 I noticed that jquery's beta template plugin is using, the type attribute "text/x-jquery-tmpl" e.g <script type="text/x-jquery-tmpl"> I've not seen custom use of the type attribute in the past. Has anyone seen current examples of this in use or perhaps ways mere mortal developers such as I can use this in our own code? I presume that it's sort of a MIME type, however I would of thought that MIME type support was up to the browser. So I would of assumed that custom MIME types would be

load jQuery-Templates from external file?

▼魔方 西西 提交于 2019-11-28 19:17:59
I just started using jQuery's template engine. Which looks quite nice so far. Yet i wonder if it's possible to load templates from an external file somehow. Imagine having loads of templates. This would mess up the html-code and is also not cacheable and has to be downloaded on every request. I was hoping there is a way to define them all in an external file and then load them and store the compiled templates into localStorage. Does anyone have an idea how to load them from an external file? Floyd you can load this template with ajax. <script> var movies = [ { Name: "The Red Violin",

Access index of $parent in knockout.js

ぃ、小莉子 提交于 2019-11-28 16:36:41
In knockout.js 2.1.0, in a template using the foreach binding, you can access the current item's index though the $index() function. In a nested foreach binding, is there any way to access the index of the $parent from a template? Say I have a data structure like this: var application = { topModel: [ { {subModel: [{'foo':'foo'}, { 'bar':'bar'}]}, // this has top:0 and sub:0 {subModel: [{'foo2':'foo2'}, { 'bar2':'bar2'}]} // this has top:0 and sub:1 }, { {subModel: [{'foo':'foo'}, { 'bar':'bar'}]} // this is top:1 sub:0 }, { {subModel: [{'foo':'foo'}, { 'bar':'bar'}]} // this is top:2 sub:0

Simplest way to get current item index within jQuery template

廉价感情. 提交于 2019-11-28 06:48:17
I am passing an array of objects to jQuery template (official jquery-tmpl plugin): $("#itemTmpl").tmpl(items).appendTo("body"); <script id="itemTmpl" type="text/x-jquery-tmpl"> <div class="item">Name: ${name}, Index: ${???}</div> </script> What is the easiest way to display item index in the template? Preferably without using separated external functions, without changing passed object structure, and without changing template structure (converting to {{each}} ). Is there any built-in variable perhaps that stores current array index? UPDATE I created a ticket proposing to expose array index to

jQuery Templates not working in IE9 RC

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 04:56:29
问题 Just upgraded to the RC of IE9 and found that my web pages using jQuery Templates are not rendering the template content. Pages work fine when I switch to IE8 Browser Mode in the Developer Tools (and Safari, FF, etc). Anyone got any ideas? 回答1: There is now a RC version of jQuery v1.5 - here That should fix your problems with jQuery on IE9 RC. Full version of jQuery 1.5.1 is due to be released very soon. 回答2: The issue was caused by a bug in jQuery 1.5 when running on an IE9. The only way to