I ported a plugin I wrote a while ago to jmvc that fakes html5 placeholder behavior. It mostly works except I have one peculiar problem:
I need to capture clicks on the parent box of the label and input field and simulate a focus event on the field. This will cover both both types of focus: click on field and tab to field. I did it this way to that the click would always bubble up to a focus even if you clicked on the label which is superimposed on the field (twitter does this, among many others). In the controller init() I have:
- this.delegate(this.element.parent(),'', 'click', function(ev) {
- self.element.trigger("focus"); // I've debugged to here, this is indeed firing on parent click
- return false;
- });
And in my controller I simply bind to 'focus':
- 'focus' : function() {
- // though, we never get here for some reason, unless we tab into a field
- if (this.valState == "empty") {
- this.setLabelState('dim');
- } else {
- this.setLabelState('hide');
- }
- }
Am clearly missing something obvious but still quite stumped.