Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I do radio buttons in Ember?

Is there possibility in handlebars to do something like

{{input type="radio" checked=model.isAdmin}}Admin 
{{input type="radio" checked=model.isGuest}}Guest

property of model, model.isAdmin return true or false. Because handlebars version is 1.3.0. answer on this question doesn't help me!

like image 706
SrIl Avatar asked Mar 10 '23 01:03

SrIl


1 Answers

Actually that pretty easy using closure actions:

<input type="radio" name="isAdmin" checked=isAdmin onclick={{action (mut isAdmin) true}} />

<input type="radio" name="isAdmin" checked={{not isAdmin}} onclick={{action (mut isAdmin) false}} />

Well, if I understood you correctly isGuest means not admin. However if its something different, its a very flexible approach, so you probably can do what you want.

However to mention is the not helper I'm using. For this you should check out ember-truth-helpers.

Here is a working twiddle with this solution.

like image 61
Lux Avatar answered Mar 19 '23 22:03

Lux