Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placeholder in IE7

I have tired a few placeholder plugins to get it to work in IE. Currently I'm using http://widgetulous.com/placeholderjs/. This works in IE8 & 9 but not IE7. It throws a SCRIPT1028: Expected identifier, string or number placeholder.js, line 182 character 5 SCRIPT5009: 'Placeholder' is undefined csr-form.html, line 72 character 3 - This is where I call the placeholder.js via:

$(function(){
    // Placeholder
    Placeholder.init();
});

Does anyone know how to get this to work in IE7 or can someone suggest another plugin that works in IE7?

UPDATED Here is the fiddle, http://jsfiddle.net/clintongreen/NLWRL/

Thanks

like image 303
Clinton Green Avatar asked Nov 04 '11 01:11

Clinton Green


2 Answers

I'm using Placeholder-jQuery-Plugin by mathiasbynens at work.

It says IE6+ is supported, and we haven't had any troubles with IE7.

Usage is nice — set the placeholder attribute in your input tags and call $('input').placeholder(); in your $(function())

like image 177
sghill Avatar answered Nov 04 '22 06:11

sghill


ah, your problem is a trailing comma in a hash like this

{
 'this':'blows',
 'up': 'ie7',
}

edit: yep i see it, your utils hash in that fiddle has a trailing comma after it.

here is the fix: http://jsfiddle.net/NLWRL/1/

not tested in ie7, there might be more trailing commas hiding in there for you to find

by the way when you see Expected identifier, string or number in ie7, 9/10 times its a trailing comma.

like image 25
mkoryak Avatar answered Nov 04 '22 06:11

mkoryak