handlebars.js

Calling a handlebars block helper from another helper

女生的网名这么多〃 提交于 2019-12-08 18:46:49
问题 How can I call a handlebars block helper from another helper in ember. I am interested in converting the following in a bound helper. {{#each link in sideMenuLinks}} <li class="navigation page"> {{#linkTo ROUTE_VARIABLE link.linkToRouteContext}} {{{link.iconTag}}}<i class="icon-right-open"></i>{{link.linkText}}</a> {{/linkTo}} </li> {{/each}} Note that I will have to call a {{#linkTo}} block inside the helper and also change ROUTE_VARIABLE with a value from the property link.linkToRoute. 回答1:

How to trigger an action when an input gets focus?

那年仲夏 提交于 2019-12-08 17:43:51
问题 I want to know how to trigger an action when an input gets focused.. right now I'm using this on my template: {{view "clickinput" class="form-control" placeholder="search..." value=s action="focus"}} and this as the view: export default Ember.TextField.extend({ onEvent: 'focusIn', focusIn: function() { this.sendAction('focusIn', this, event); } }); and this on my controller: actions: { focus: function() { alert('f'); } } but it doesn't work.. I get this error on chrome: Uncaught Error:

Display the first item in hasMany ember relationship in handlebars template

感情迁移 提交于 2019-12-08 17:40:03
问题 I need to display the first item in an hasMany relationship Basically a thread could have more than 1 author but I need to display only the first one in a particular template I've the following json { threads: [ { id: 1, authors: [2,3] } ], authors: [ { id: 2, fullname: "foo" }, { id: 3, fullname: "bar" } ] } And the following models App.Thread = DS.Model.extend({ authors: DS.hasMany('author') }); App.Author = DS.Model.extend({ fullname: DS.attr('string') }); now in my template I'm tring to

How to make grunt watch subfolder for handlebars templates (ember.js app with Yeoman)

瘦欲@ 提交于 2019-12-08 13:34:40
问题 When you create an ember app with Yeoman, it create a handlebars templates folder for you (.hbs). The yeoman config is set that way : watch: { ember_templates: { files: '<%= yeoman.app %>/templates/**/*.hbs', tasks: ['ember_templates', 'livereload'] }, When a template is in the folder root, it works When a template is in a subfolder template/mySubfolder the template is not rendered (no html is returned) When a template is missing, ember throw an error So when the template is in a subfolder,

How to render dynamic table without knowing the data? using HTML and JS

醉酒当歌 提交于 2019-12-08 12:39:59
问题 By dynamic I mean that I don't know what is the data returned from the ajax response. I managed to return {name:"" value:""} pair for some leverage. sample data: [ [ { "name": "_id", "value": "5a32391133425e1f5436161b" }, { "name": "Issue", "value": "Splash Screen Animations" }, { "name": "Status", "value": "Done" }, { "name": "Comment", "value": "The animation must be the same as ios" } ], [ { "name": "_id", "value": "5a32391133425e1f5436161c" }, { "name": "Issue", "value": "Live Streaming

Ember.TextField submit on keyup event

旧街凉风 提交于 2019-12-08 12:00:38
问题 I have Handlebars view with the following search input field: {{view Ember.TextField valueBinding="controller.query" action="submit"}} when a user presses 'Enter' from the search input field, we make a call to an external API, get response, and query the results accordingly. Here is the code of the (simplified) version of the controller: App.ProductsController = Ember.ArrayController.extend({ submit: function(query) { // call to external api // get response // update some values } }); How do

Display json data with simplePagination.js?

ぃ、小莉子 提交于 2019-12-08 11:47:53
问题 PAGINATION DEMO I am developing a pagination with handlebars.js & simplePagination.js Data is loaded from JSON and displayed using handlebars.js Now I have to Map JSON DATA TO PAGINATION , where do I do it? Apart from this there is not Much Documentation in the official website "http://flaviusmatis.github.io/simplePagination.js" Request your kind help. Any advice / suggestions are greatly appreciated. JS CODE : $(function () { function loadPosts(posts) { $('#posts').empty(); posts.each

jQuery Asynchronous programming pattern?

本秂侑毒 提交于 2019-12-08 11:33:18
问题 I have inherited an app that scans a page looking for data attributes and modifies the dom, adding handlers, etc, accordingly. I was asked to implement dynamic markup whereby I issue an ajax call to get json data and then use Handlebars to render the new html based on the returned data. I need to tell the main, outer app to wait until all of the json calls have been resolved before it goes looking for data attributes. What sort of pattern should I put in place to do this? Any help would be

Escape single quotes in JSON.stringify

青春壹個敷衍的年華 提交于 2019-12-08 11:06:01
问题 I know, I don't need it, but I think I actually do. I want to have a valid JS code rendered by handlebarsjs before it is even rendered. The JS minification tools just minify valid JS files and minifying on the fly increases processing time. This is the JS handlebars code. var stringsObj = JSON.parse('{{{ json stringsDataObj }}}'); As you see, the single quotes up-there make that line of code a valid JS code. The handlebars helper is: function json(context) { return JSON.stringify(context); }

Nested {{each}} loops with Handlebars template

两盒软妹~` 提交于 2019-12-08 10:39:46
问题 Im trying to iterate an Array of Objects for putting their values in a Handlebars template using the each loop inside the structure of the array. Here you can see the array: var datosSensores = [ { name:'John Pinard', email:'jp@aol.com', ph: [ '7.80', '7.90', '7.60', fecha: [ '2016-06-20 09:00', '2016-06-21 10:00' ], ], } ]; And the each loop if've tried as you can see: {{#each ph}} .... ..... {{#each ph.fechaPH}} {{this.fechaPH}} //This would be the value of each DATE in the array {{/each}}