handlebars.js

jQuery Mobile / Handlebars - Opening a panel hides the data-role=content div

大兔子大兔子 提交于 2019-12-01 09:15:16
问题 I'm trying to use Handlebars with jQuery mobile. I'm using jQuery 1.9.1, jQueryMobile 1.4, Handlebars 1.1.2. <div data-role="page" id="attach-template"> <div data-role="panel" id="mypanel"> <div data-role="header"> <h1>Title</h1> </div><!-- /header --> <nav> <ul> <li><a href="index.html">Home</a></li> <li><a href="promotions.html">Promotions</a></li> <li><a href="events.html">Events</a></li> </ul> </nav> </div> <script id="content-template" type="text/x-handlebars-template"> <div data-role=

Why is browser returning error “TypeError: this._input is null” in Firefox (and similar in Chrome) when using handlebars.js?

*爱你&永不变心* 提交于 2019-12-01 08:10:13
This is the code I am trying out: http://jsfiddle.net/sbrsK/10/ It runs correctly without any error in jsfiddle Trying to run the same via a web-server locally on my computer does not work. The following files are being loaded: index.html app.js In Firefox I get this error: TypeError: this._input is null @ http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js:364 In chrome I get this error: Uncaught TypeError:Cannot call method 'match' of null under match = this._input.match(this.rules[rules[i]]); in handlebars-1.0.0.beta.6.js There is a very similar problem raised

Meteor template: Pass a parameter into each sub template, and retrieve it in the sub-template helper

你说的曾经没有我的故事 提交于 2019-12-01 08:04:10
I am trying to figure out how to pass a parameter into a sub-template that is in an each block and use the parameter in the sub-template as well as sub-template helper. Here is what I tried so far: template: <template name="parent"> {{#each nodes }} {{> child myParam}} {{/each}} </template> <template name="child"> {{ paramName }} </template> js: Template.parent.nodes = function() { //return a list }; Template.parent.myParam = function() { return {"paramName" : "paramValue"}; }; Template.child.someOtherHelper = function() { //How do I get access to the "paramName" parameter? } So far, it hasn't

Add css classes to <body> in Ember.js

老子叫甜甜 提交于 2019-12-01 07:25:58
问题 How to add css class to the body tag on specific route? I tried to use body tag in a handlebars template but didn't work... Update: After some googling I came with this solution. Not sure that this is the best way to do this, but it works. App.SomeRoute = Em.Route.extend activate: -> Em.$('body').addClass 'some-class' deactivate: -> Em.$('body').removeClass 'some-class' 来源: https://stackoverflow.com/questions/20781154/add-css-classes-to-body-in-ember-js

Why is browser returning error “TypeError: this._input is null” in Firefox (and similar in Chrome) when using handlebars.js?

自闭症网瘾萝莉.ら 提交于 2019-12-01 07:19:56
问题 This is the code I am trying out: http://jsfiddle.net/sbrsK/10/ It runs correctly without any error in jsfiddle Trying to run the same via a web-server locally on my computer does not work. The following files are being loaded: index.html app.js In Firefox I get this error: TypeError: this._input is null @ http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js:364 In chrome I get this error: Uncaught TypeError:Cannot call method 'match' of null under match = this.

How to get the result of a Meteor.call function in a template

心不动则不痛 提交于 2019-12-01 05:56:07
I'm trying to make a pagination function for use in a Meteor client. Therefore I need to know the record count on the server. On the server (in server/bootstrap.coffee) I have this code: Meteor.methods ContactsCount: -> Contacts.find().count() console.log("Totalrecords: " + Contacts.find().count()) The server part is called (it displays the correct number on the console - 40) On the client I have: $.extend Template.pager, GetRecordCount: -> Meteor.call("ContactsCount", (error,result) -> console.log('r', result) From the browser console Template.pager.RecordCount() returns undefined r 30 I

Meteor template: Pass a parameter into each sub template, and retrieve it in the sub-template helper

纵饮孤独 提交于 2019-12-01 05:49:06
问题 I am trying to figure out how to pass a parameter into a sub-template that is in an each block and use the parameter in the sub-template as well as sub-template helper. Here is what I tried so far: template: <template name="parent"> {{#each nodes }} {{> child myParam}} {{/each}} </template> <template name="child"> {{ paramName }} </template> js: Template.parent.nodes = function() { //return a list }; Template.parent.myParam = function() { return {"paramName" : "paramValue"}; }; Template.child

Getting the last element from a JSON array in a Handlebars template

非 Y 不嫁゛ 提交于 2019-12-01 05:20:05
So, I found that array elements can be accessed in Handlebars using: {{myArray.2.nestedObject}} and {{myArray.0.nestedObject}} ..to get the third and first elements for instance. ( handlebars-access-array-item ) Is there a way to get the last element from an array? I tried creating a helper for it: Handlebars.registerHelper("lastElement", function(array) { return array.last(); //Array.prototype extension }); ...and calling it as follows in the template: {{lastElement myArray}} or even {{lastElement myArray.lastElement nestedArray}} Sadly, this doesn't work. Helper functions return strings

Is there a way to ignore Handlebars templates within a Handlebars template?

久未见 提交于 2019-12-01 04:17:09
问题 I'm using Express + Handlebars in my server side node application, and I want to send client templates to the browser as part of the page that I'm rendering. index.html <html> <head> <title>{{title}}</title> </head> <body> <div> {{stuff}} </div> <script id="more-template" type="text/x-handlebars-template"> <div>{{more}}</div> </script> </body> Unfortunately, handlebars tries to render the stuff in the #more-template script block. (Which just removes the {{more}} because it's undefined in the

How can I dynamically insert a new template into the DOM with Ember?

偶尔善良 提交于 2019-12-01 04:11:28
I have an Ember.js app. In the main template I have a help button that when clicked should display a CSS tooltip. I have the tooltip is a separate Handlebars template. What I'm trying to do is handle the click event to insert the popup into the DOM and display it. I cannot figure out how to insert new templates into the DOM using Ember. Here's my template where the help button is displayed: <div id="status_help" class="icon_help" {{action "helpClicked"}}></div> Here's my primary view: var checkbox = Ember.Checkbox.extend({ templateName: 'checkbox', helpClicked: function(e) { // Not sure what