{"id":165,"date":"2010-02-10T10:16:11","date_gmt":"2010-02-10T09:16:11","guid":{"rendered":"https:\/\/www.hutsky.cz\/blog\/?p=165"},"modified":"2010-02-11T10:40:43","modified_gmt":"2010-02-11T09:40:43","slug":"internet-explorer-expected-identifier","status":"publish","type":"post","link":"https:\/\/www.hutsky.cz\/blog\/2010\/02\/internet-explorer-expected-identifier\/","title":{"rendered":"Internet Explorer: Expected Identifier"},"content":{"rendered":"<p style=\"text-align: justify;\">Today, I got feedback about a bug in an application in which I did some minor alterations not long ago. The application gives several rather long lists containing names and as it was often quite difficult to tell which list you are viewing after scrolling down a little bit, I was asked to do something about it. There was no easier way than to show only the first ten names of each list and put the rest in a hidden container, which is shown with help of a &#8220;show more&#8221; link.<\/p>\n<pre lang=\"html\">\r\n<a id=\"i_box10\" class=\"show_hidden_list\" href=\"#\">see more \/ hide \u00bb \u00bb<\/a>\r\n<div class=\"hiddenclass show_box10\">...list....<\/div>\r\n<\/pre>\n<p><!--more--><\/p>\n<p>And just a few lines of jQuery that do the magic.<\/p>\n<pre lang=\"javascript\">\r\n$(document).ready(function() {\r\n\t\t\t$('a.show_hidden_list').click(function(e){\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\tvar class = this.id.replace('i_', \"\");\r\n\t\t\t\t$(\".show_\"+ class +\"\").toggle();\r\n\t\t\t});\r\n\t});\r\n<\/pre>\n<p style=\"text-align: justify;\">Every time you click a link with <em>show_hidden_list<\/em> class, a function is called that first of all prevents the usual behaviour of a link, then gets the name of the desired <em>div<\/em> from the current link&#8217;s id and stores it in a variable called <em>class<\/em>. The name of this variable was chosen because it is the name of the actual class that will be shown with help of jQuery.<\/p>\n<p style=\"text-align: justify;\">Everything worked fine until I received feedback from a client that it&#8217;s not working in IE8, spitting out &#8220;Expected Identifier&#8221; error.\u00a0I usually test things I do in all major browsers, but might have forgotten this time with such a tiny change. Now, on closer look I found out IE6 had troubles as well as IE8 (with compatibility mode on).<\/p>\n<p style=\"text-align: justify;\">After some tempering, I discovered that Internet Explorer considers the word <em>class<\/em> to be reserved and that is what was causing troubles. Could have anticipated something like this so shame on me. Anyway, all I had to do then was to change the name of the variable.<\/p>\n<pre lang=\"javascript\">\r\n $(document).ready(function() {\r\n\t\t\t$('a.show_hidden_list').click(function(e){\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\tvar just_other_name = this.id.replace('i_', \"\");\r\n\t\t\t\t$(\".show_\"+ just_other_name +\"\").toggle();\r\n\t\t\t});\r\n\t});\r\n<\/pre>\n<p style=\"text-align: justify;\">\n","protected":false},"excerpt":{"rendered":"<p>Today, I got feedback about a bug in an application in which I did some minor alterations not long ago. The application gives several rather long lists containing names and as it was often quite difficult to tell which list &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.hutsky.cz\/blog\/2010\/02\/internet-explorer-expected-identifier\/\"> <span class=\"screen-reader-text\">Internet Explorer: Expected Identifier<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[50],"class_list":["post-165","post","type-post","status-publish","format-standard","hentry","category-jquery","tag-jquery"],"_links":{"self":[{"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/posts\/165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/comments?post=165"}],"version-history":[{"count":39,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/posts\/165\/revisions"}],"predecessor-version":[{"id":208,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/posts\/165\/revisions\/208"}],"wp:attachment":[{"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/media?parent=165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/categories?post=165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/tags?post=165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}