jquery-templates

jQuery Templates vs Partial Views in ASP.NET MVC

断了今生、忘了曾经 提交于 2019-12-03 03:11:02
I'm taking a look at jQuery templates. It looks really interesting - easy syntax, easy to use, very clean. However, I can't really see why it's better to use jQuery templates instead of simply fetching partial views via AJAX. It simply seems like the partial views would be much easier to maintain and helps to avoid duplication of code. I want to use jQuery templates. But when would it be better than partial views? I agree that these do overlap. There are several different ways to implement the same piece of software, and much of your decision on what to use depends on your personal preference

Avoiding ambiguous mustaches from Jinja2 that includes jQuery templates

独自空忆成欢 提交于 2019-12-03 03:08:00
问题 I'm trying to insert jQuery templates into Jinja2 templates. Alas they both (in the default setup) use the mustaches {{ & }} to indicate expressions and literals, respectively. I'm inserting my jQuery templates into HTML with script tags, like this: <script type='text/x-jquery-template'> <div>The people are: {{ each people }} ${$value} {{ /each }} </div> </script> If the above is in a Jinja template, however, it balks because Jinja tries to interpret each as a literal. In the circumstances

Can I do a jquery-tmpl each over object properties

大兔子大兔子 提交于 2019-12-03 02:46:37
The template {{each}} directive works great for iterating over an array like this: var myArray = ["a","b","c"]; I'm wondering if there is an equivalent for iterating over object properties, i.e.: var myObj = {"propOne": "a", "propTwo": "b", "propThree": "c"}; I'd like a template that would let me output as <ul> <li><span>propOne</span><span>a</span></li> .... etc For bonus points I'd like to use this template from KnockoutJS. Actually {{each}} will walk through properties on an object. You can do something like this: {{each(prop, val) myObj}} <li><span>${prop}</span> - <span>${val}</span></li>

Avoiding ambiguous mustaches from Jinja2 that includes jQuery templates

六月ゝ 毕业季﹏ 提交于 2019-12-02 17:41:09
I'm trying to insert jQuery templates into Jinja2 templates. Alas they both (in the default setup) use the mustaches {{ & }} to indicate expressions and literals, respectively. I'm inserting my jQuery templates into HTML with script tags, like this: <script type='text/x-jquery-template'> <div>The people are: {{ each people }} ${$value} {{ /each }} </div> </script> If the above is in a Jinja template, however, it balks because Jinja tries to interpret each as a literal. In the circumstances (we've lots of templates already) it isn't practical to change Jinja2's start and end delimiters for

KnockoutJS: Tracking menu clicks

做~自己de王妃 提交于 2019-12-02 08:54:27
问题 I have just started playing with KnockoutJS and it it fascinating. I successfully created some templates to render two panels of an interface with "ul" nested menus inside. Here are my templates: <script id="menuItemTemplate" type="text/html"> <li class='${ Class }' > <a class='${ Class }' data-bind='click: function() { viewModel.menuClicked(Id); }'>${ Name }</a> <ul class='${ Class }' data-bind='template: { name: "menuItemTemplate", foreach: Items }'></ul> <li> </script> <script id=

KnockoutJS: Tracking menu clicks

霸气de小男生 提交于 2019-12-02 04:04:50
I have just started playing with KnockoutJS and it it fascinating. I successfully created some templates to render two panels of an interface with "ul" nested menus inside. Here are my templates: <script id="menuItemTemplate" type="text/html"> <li class='${ Class }' > <a class='${ Class }' data-bind='click: function() { viewModel.menuClicked(Id); }'>${ Name }</a> <ul class='${ Class }' data-bind='template: { name: "menuItemTemplate", foreach: Items }'></ul> <li> </script> <script id="menuTemplate" type="text/html"> <ul class='${ Class }' data-bind='template: { name: "menuItemTemplate", foreach

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

女生的网名这么多〃 提交于 2019-12-02 02:42:59
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 player vanish again. The 'if' binding is necessary due to the fact that there may be many instances of

Show progress bar while knockout is rendering the view

删除回忆录丶 提交于 2019-11-30 14:34:40
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: function (element, valueAccessor) { viewModel.updateProgressBar(); } }; ... <ul data-bind="template: {name:

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

╄→尐↘猪︶ㄣ 提交于 2019-11-30 08:37:08
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? jQuery Templating provides $.template() (see description in source code) - it returns array of strings after evaluating cached template with your data. I am writing from scratch (and from experiments in Chrome's console), but

jQuery templates - where should I put them?

大城市里の小女人 提交于 2019-11-30 05:21:37
问题 At the moment I have a single html page that has 4 templates in it and will have many more. Is it possible to put the templates in different files and "import" them in? Can I define them in a .js file? I'm using jQquery template plugin: http://api.jquery.com/category/plugins/templates/ My code looks like the examples! 回答1: I mostly agree with this answer's spin: Where to keep html templates? You're already doing the right thing, because of the KISS principle. Depending on how many templates