handlebars.js

Emberjs-1.0.0-rc.6 click to dynamically add more or multiple input fields

别等时光非礼了梦想. 提交于 2019-12-08 03:36:50
问题 I want to create a form where uses can click a button to add additional input fields. I have created a partialy working here jsfidle and the entire code in the jsfiddle is pased below: I have 3 problems: This adds a textfield but is not using ember bindings $("#addField").append(' ') . When I try to the version that relies on handlebars I means this: ** $("#addField").append('{{textArea value=name}} ') , instead of the output being a **textArea , I get just {{textArea value=name}} Since the

Handlebars precompiled templates returns undefined value

筅森魡賤 提交于 2019-12-08 03:29:26
I have a template file test_temp.handlebars. Its content is, <div>Hello {{name}}</div> I compiled the template in my command line using the command, handlebars test_temp.handlebars -f test_temp.js The content of the test_temp.js file is, (function() { var template = Handlebars.template, templates = Handlebars.templates =Handlebars.templates || {}; templates['test_temp'] = template({"compiler":[5,">=2.0.0"],"main":function(depth0,helpers,partials,data) { var helper, functionType="function", escapeExpression=this.escapeExpression; return "<div>Hello " + escapeExpression(((helper = helpers.name |

Handlebars.registerHelper - Way to get content of Block?

╄→尐↘猪︶ㄣ 提交于 2019-12-08 03:02:47
问题 is there a way in registerHelper to get the content of a block? Lets assume we have the following template: {{#myif test}}thats the content i want to have{{/myif}} And the following registerHelper Code: Ember.Handlebars.registerBoundHelper('myif', function(test) { // do something return <content of handlebars block>; }); Many thanks! 回答1: Handlebars provides the nested block to the helper as options.fn , where options is the last argument of your helper. You can invoke this block with a

How to pass Model route name item to linkTo in template in ember.js

你离开我真会死。 提交于 2019-12-08 00:59:38
问题 How do I pass a route name to a {{linkTo}} dynamically? For example, given this code: App.Router.map(function() { this.resource('anon', {path: '/main'}, function() { this.route('home', {path:'/home'}); this.route('about', { path: '/about' }); this.route('contact', { path: '/contact' }); }); }); App.NavController = Ember.ArrayController.extend({ selectedNav:'', setNav:function(value){ var nav = App.Nav.find(value); var items = nav.get('navItems'); this.set('content', items); } }); these

Lookup helper in handlebars

别等时光非礼了梦想. 提交于 2019-12-08 00:22:02
问题 I have a 'countries' object which I pass as part of the Handlebars context: { 'hk': {'name': 'Hong Kong', 'someotherprop': 'someothervalue'}, 'us': {'name': 'United States', 'someotherprop': 'yetanothervalue'}, ... } I want to use the lookup Handlebar helper to find from the countrycode 'hk' the name 'Hong Kong'. I can get the following object {'name': 'Hong Kong', 'someotherprop': 'someothervalue'} using the following Handlebars directive {{lookup ../countries countrycode}} but how do I now

set focus in an ember application

独自空忆成欢 提交于 2019-12-07 23:23:53
问题 I want to be able to set the focus to a textarea as a result of a mouse click not in that task area. As a minimal example, let's say that I'm starting with a text and if you click on it, it gets replaced with a textfield. I can achieve this by a handlebars script: <script type="text/x-handlebars"> {{#if isActive}} {{view Ember.TextField}} {{else}} <p {{action foo}}> Click Here to Enter text </p> {{/if}} </script> with a controller of App.ApplicationController = Ember.Controller.extend({

Creating a dynamic string with bindAttr

懵懂的女人 提交于 2019-12-07 21:56:46
问题 I'd like to create a dynamic classname on an object with a value I'm getting from my model. One of the keys is named provider which contains either "twitter" or "facebook". What I'd like to do is to prepend the string "icon-" to the provider so that the resulting class is icon-twitter or icon-facebook . This is the code that I've got now. <i {{bindAttr class=":avatar-icon account.provider"}}></i> Ember offers a way to include a static string within the attribute by prepending : to it. You can

Emberjs: Cannot createRecord with Ember Data 1.0.0 beta

自作多情 提交于 2019-12-07 20:48:16
问题 I have an app that keeps multiple task lists. Each task list has multiple tasks. Each task has multiple comments. After updating to the new Ember Data, I had to scrap my record creation code. Currently I have this, which doesn't work. Though it doesn't throw any errors, my model does not seem to be updating. App.TaskController = Ember.ArrayController.extend({ needs : ['list'], isEditing : false, actions : { addTask : function(){ var foo = this.store.createRecord('task', { description : '',

ember handlebars: find where component/helper/variable is defined

本小妞迷上赌 提交于 2019-12-07 17:57:37
Given some handlebars code like this: {{ui.select param1="foo" param2="bar"}} How could I find out where ui.select is defined? (I happen to be on Ember 2.13) because this contains a . this comes from a contextual component. so first find out where ui comes from. Probably you have something like this: {{#my-component as |ui|}} {{ui.select ...}} {{/my-component}} Then you have to check the my-component and find out what ui is assigned to in the {{yield}} . 来源: https://stackoverflow.com/questions/49390867/ember-handlebars-find-where-component-helper-variable-is-defined

Ember link-to Set Active Class Immediately

自作多情 提交于 2019-12-07 17:04:27
问题 I have a nav bar that has special CSS that shows up when a link has the "active" class on it. It looks something like this: <ul> <li>{{link-to "routeName"}}<i class="icon-up"></i>{{/link-to}}</li> {{!-- more list items like the previous one... --}} </ul> However, when I click on the link with "routeName" , a rather expensive query is made that may be slow at times. I have a LoadingRoute set up with a loading view that consists of a simple spinner, but it seems like the link does not receive