dcneiner/In-Field-Labels-jQuery-Plugin — Issue #19: Bug with colon in ID
Author: AnnaVakulchik
Created: 2011-10-10 07:20:49+00:00
State: open

I found out some bug if you have colon in ID of element. I integrated you plugin in Magento and faced with this problem.

It can be easily fixed by adding : for_attr = for_attr.replace(":", "\\:");

$.fn.inFieldLabels = function(options){
return this.each(function(){
// Find input or textarea based on for= attribute
// The for attribute on the label must contain the ID
// of the input or textarea element
var for_attr = $(this).attr('for');
if( !for_attr ) return; // Nothing to attach, since the for field wasn't used
for_attr = for_attr.replace(":", "\\:");
// Find the referenced input or textarea element
var $field = $(
"input#" + for_attr + "[type='text']," +
"input#" + for_attr + "[type='password']," +
"textarea#" + for_attr
);

if( $field.length == 0) return; // Again, nothing to attach

// Only create object for input[text], input[password], or textarea
(new $.InFieldLabels(this, $field[0], options));
});
};

})(jQuery);