# {{bind-attr}} not working with colspan why?

**URL:** <https://discuss.emberjs.com/t/bind-attr-not-working-with-colspan-why/4285>\
**Category:** Uncategorized\
**Created:** [February 27, 2014, 7:03am UTC](https://discuss.emberjs.com/t/bind-attr-not-working-with-colspan-why/4285 "2014-02-27T07:03:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![YIk](https://avatars.discourse-cdn.com/v4/letter/y/a5b964/32.png) [@YIk](https://discuss.emberjs.com/u/YIk)\
**Post date:** [February 27, 2014, 7:03am UTC](https://discuss.emberjs.com/t/bind-attr-not-working-with-colspan-why/4285/1 "2014-02-27T07:03:19Z")

</div>

bind-attr not working with colspan

---

<div class="post-metadata">

**Author:** ![alexspeller](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/alexspeller/32/14812_2.png) [@alexspeller](https://discuss.emberjs.com/u/alexspeller)\
**Post date:** [February 27, 2014, 4:48pm UTC](https://discuss.emberjs.com/t/bind-attr-not-working-with-colspan-why/4285/2 "2014-02-27T16:48:02Z")

</div>

[It works fine](http://emberjs.jsbin.com/mayoceha/1/edit)

---

<div class="post-metadata">

**Author:** ![YIk](https://avatars.discourse-cdn.com/v4/letter/y/a5b964/32.png) [@YIk](https://discuss.emberjs.com/u/YIk)\
**Post date:** [February 28, 2014, 5:32am UTC](https://discuss.emberjs.com/t/bind-attr-not-working-with-colspan-why/4285/3 "2014-02-28T05:32:26Z")

</div>

@alexspeller Thank you, Ya it’s work for me but I want to set colspan count based on the property

like : `<td {{bind-attr colspan='setColspan:2:1'}}>FOO</td>`, how can achieve this one

---

<div class="post-metadata">

**Author:** ![jasonmit](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jasonmit/32/182_2.png) [@jasonmit](https://discuss.emberjs.com/u/jasonmit)\
**Post date:** [February 28, 2014, 8:37am UTC](https://discuss.emberjs.com/t/bind-attr-not-working-with-colspan-why/4285/4 "2014-02-28T08:37:31Z")

</div>

@YIk like [http://emberjs.jsbin.com/dogut/1/edit](http://emberjs.jsbin.com/dogut/1/edit)

---

<div class="post-metadata">

**Author:** ![YIk](https://avatars.discourse-cdn.com/v4/letter/y/a5b964/32.png) [@YIk](https://discuss.emberjs.com/u/YIk)\
**Post date:** [February 28, 2014, 10:34am UTC](https://discuss.emberjs.com/t/bind-attr-not-working-with-colspan-why/4285/5 "2014-02-28T10:34:08Z")

</div>

@jasonmit Thank you, I did this workaround but I want use with single property.

like `<td {{bind-attr class="showRed:redBG:yellowBG" }}>FOO</td` here showRed is true apply redBG class otherwise apply yellowBG. Here we done with single property works, but colspan not work like this.

---

<div class="post-metadata">

**Author:** ![alexspeller](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/alexspeller/32/14812_2.png) [@alexspeller](https://discuss.emberjs.com/u/alexspeller)\
**Post date:** [February 28, 2014, 12:04pm UTC](https://discuss.emberjs.com/t/bind-attr-not-working-with-colspan-why/4285/6 "2014-02-28T12:04:57Z")

</div>

You cannot. Only classes work like this, not other attributes.

---

<div class="post-metadata">

**Author:** ![Jun\_Andrew\_Hu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jun_andrew_hu/32/224_2.png) [@Jun\_Andrew\_Hu](https://discuss.emberjs.com/u/Jun_Andrew_Hu)\
**Post date:** [March 1, 2014, 1:35am UTC](https://discuss.emberjs.com/t/bind-attr-not-working-with-colspan-why/4285/7 "2014-03-01T01:35:03Z")

</div>

It does work:

```
<td {{bindAttr colspan="view.columnNumbers"}}

```

---

<div class="post-metadata">

**Author:** ![YIk](https://avatars.discourse-cdn.com/v4/letter/y/a5b964/32.png) [@YIk](https://discuss.emberjs.com/u/YIk)\
**Post date:** [March 4, 2014, 11:50am UTC](https://discuss.emberjs.com/t/bind-attr-not-working-with-colspan-why/4285/8 "2014-03-04T11:50:46Z")

</div>

@Jun_Andrew_Hu thank you, but it’s also seems like workaround.

---

<div class="post-metadata">

**Author:** ![JulianLeviston](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@JulianLeviston](https://discuss.emberjs.com/u/JulianLeviston)\
**Post date:** [March 9, 2014, 1:45pm UTC](https://discuss.emberjs.com/t/bind-attr-not-working-with-colspan-why/4285/9 "2014-03-09T13:45:43Z")

</div>

Hi, I used to have similar issues. It seems like a workaround because you’re trying to put logic into your templates, but handlebars kind of precludes you from doing this. It’s better to put the logic in the controller. Separation of concerns.

> **[Separation of concerns](https://en.wikipedia.org/wiki/Separation_of_concerns)**
>
> In computer science, separation of concerns is a design principle for separating a computer program into distinct sections. Each section addresses a separate concern, a set of information that affects the code of a computer program. A concern can be as general as "the details of the hardware for an application", or as specific as "the name of which class to instantiate". A program that embodies SoC well is called a modular program. Modularity, and hence separation of concerns, is achieved by e Se...

---

<div class="post-metadata">

**Author:** ![jasonmit](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jasonmit/32/182_2.png) [@jasonmit](https://discuss.emberjs.com/u/jasonmit)\
**Post date:** [March 10, 2014, 7:14am UTC](https://discuss.emberjs.com/t/bind-attr-not-working-with-colspan-why/4285/10 "2014-03-10T07:14:53Z")

</div>

If you’re concerned about putting view logic on your controller, the above examples could just as easily go into the view.
