Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I know it's really not the point on the article, but I wanted to share a quick and dirty solution for a common problem, especially this:

>> If you were using jQuery to do this, you’d likely bind a function to the click event on each row. When fired, your function would change the CSS class of the row to highlight it.

>> You can’t stop there, though. Your function also has to remove the CSS class from any other rows that were previously selected. That’s a little crazy if you think about it! Changing which item is selected means we have to know everywhere that it’s been represented in our UI.

  An easy way is just to do:
  
  $('<all-row-selector..>').each(<unselect>)
      .find('<selected-row>').each(<select>)


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: