Hacker News new | ask | show | jobs
by seliopou 5476 days ago
Here's what you can do without using whenever that addresses your issue, and possibly others'. As far as I can tell what people don't like is the inlined function. You can get rid of that and be descriptive about what's going on, all without the use of whenever:

  whenever("Click Me!").is('clicked').then('change it to "clicked"')
turns into:

  var cbs = {};
  cbs.setClickedText = function() { $(this).text('Clicked!'); };

  $('a#click-me').click(cbs.setClickedText);
1 comments

Yep, I've played around with tons of approaches to this problem : your solution is where I started. It's probably totally ok, but there was something about it that just didn't sit right with me.

In eyeballs.js, for examples, I explored doing all of the binding via the html elements themselves, eg:

<a href="#" data-bind="posts#new">New Post</a>

which would map to a pre-defined posts controller new action.

whenever.js is just another exploration along the same theme. Again, I'm not arguing that it's better or worse: just my motivations for making it.