HTML5-placeholder-polyfill icon indicating copy to clipboard operation
HTML5-placeholder-polyfill copied to clipboard

Placeholder is not shown after rerendering in the react component

Open captainkovalsky opened this issue 8 years ago • 1 comments

I've found this issue in the project. How can I run again placeholders in the didUpdate method? Has this lib an api?

captainkovalsky avatar Jun 06 '16 06:06 captainkovalsky

If you want to run the placeholder polyfill always (no matter if the browser natively supports it or not) the you can simply run: $('input[placeholder], textarea[placeholder]').placeHolder();

If you want to use the native Browser implementation when it's available then do the following:

 $(function(){
    var config = window.placeHolderConfig || {};
    if(('placeholder' in $('<input>')[0] || 'placeHolder' in $('<input>')[0]) && !config.forceApply){
         // don't run the polyfill when the browser has native support
        return;
    }
    $('input[placeholder], textarea[placeholder]').placeHolder();
});

Hope it helps :-)

ginader avatar Jun 06 '16 23:06 ginader