1

The first two buttons behave as you'd expect, but the remote/js driven button does not exhibit the toggling behavior of the others.

I think this may be due to how UJS hijacks the click event, but I'm not so sure.

Any ideas on how to make this work as expected?

Right now, I have a line that does a .button('toggle') in my update.js file for this controller, but obviously theres a delay on the client side, which is bad UX.

<div class="btn-group" data-toggle="buttons-radio">
    <a class="btn btn-primary"><i class="icon-thumbs-up icon-white"></i> Accept0</a>
    <a class="btn btn-primary"><i class="icon-thumbs-up icon-white"></i> Accept1</a>
    <a class="btn btn-primary" href="some_path/update?model[key]=newvalue2" data-remote="true"><i class="icon-thumbs-up icon-white"></i> Accept2</a>
</div>
Hayk Saakian
  • 2,036
  • 2
  • 18
  • 31

1 Answers1

0

You are 100% correct with the hijacking. I am not familiar with Rails UDJ but it sounds to me as if that library is setting onclick rather than doing an attachevent (addEventListener). One overrides the event, the other adds to the event I believe. Can you verify this in code?

Eric Harms
  • 569
  • 5
  • 17
  • Read the difference between Dom Level 2s way of doing events http://stackoverflow.com/questions/6348494/addeventlistener-vs-onclick – Eric Harms Apr 20 '13 at 21:27