Style placeholder differently from value with best_in_place

Viewed 1166

I'd think I'm missing something since there seems to be no way via CSS to differentiate between a best_in_place value and the placeholder (data-nil="enter your number"). I'd just like to style the placeholder differently then the actual value so it doesn't seem confusing.

I've looked into the events and could actually add a class to the element, however when they are displayed on the page the first time, no events are available to add that class. At this point I would iterate over each $('best_in_place') and compare the nil value to that of the html in the span, however before I do this I'm just wondering if I missed something.

So is there a way to distinguish that a value has been set with best_in_place?

If code makes you understand better: This works, simply adds or removes a class to a best_in_place, however it will only be set when user edits the field, not on the inital page load.

$('.best_in_place').bind('best_in_place:update', function(evt){
    if($(this).data('nil') == $(this).html()){
      $(this).removeClass('has_value');
    }else{
      $(this).addClass('has_value');
    }
  });
2 Answers
Related