Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange Javascript issue when using placeholders html5

Im using placeholders.js but I'm getting the following error in console...

[Error] TypeError: 'undefined' is not a function (evaluating 'Placeholders.init({
                    live: true,
                    hideOnFocus: false,
                    className: "yourClass",
                    textColor: "#999"
                    })')
complete (main.js, line 416)
j (modernizr.js, line 4)
(anonymous function) (modernizr.js, line 4)
h (modernizr.js, line 4)
onload (modernizr.js, line 4)

Here is my code around these lines can anyone see whats wrong with this i have been trying all sorts for hours now and i just can't fathom it out.

if (!Modernizr.placeholder) {
Placeholders.init({
live: true,
hideOnFocus: false,
className: "yourClass",
textColor: "#999"
});    
}
like image 551
JSweete Avatar asked Apr 10 '26 19:04

JSweete


1 Answers

Were you trying to use the Brushed web page template found here? I had the same issue trying to use that template, as it contains the exact same code you posted.

To resolve my issue, I went to Placeholders' Github page to check out the interface. There, I found that there is no init() function defined in the Placeholders.js file, and under the Setup section it says:

Placeholders.js is incredibly easy to use. Just download the script, include it at the bottom of any web page and let it do the rest. It's just one extra line in your markup.

So, don't worry about calling the init() function. All you have to do is include the Placeholders.js file, nothing else. With that, my error disappeared! I know this is a late response, but I hope it helps someone.

like image 56
Sean Avatar answered Apr 13 '26 10:04

Sean



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!