This is a migrated thread and some comments may be shown as answers.

MVC Helper - HtmlAttributes in IE8 not working

3 Answers 161 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marek
Top achievements
Rank 1
Marek asked on 05 Sep 2012, 12:56 PM
Here is an example:

  @(Html.Kendo().Grid<MyViewModel>(Model.Records)
            .Name("MyGrid")
            .Columns(columns =>
            {               
                columns.Bound(c => c.Price)
                    .HtmlAttributes(new { @class = "gridColumnPrice" })
                    .Title(UIResources.Price)
                    .HeaderHtmlAttributes(new { @class = "gridColumnPrice" });
           })
            .DataSource(c => c.Server()
            )

This code generates JS as below:

jQuery(function(){jQuery("#MyGrid").kendoGrid({columns:[{title:"Price",attributes:{class:"gridColumnPrice"}, ............... ETC

In IE8 and older versions, you will get:
SCRIPT1028: Expected identifier, string or number lyKqsEz1h0Lo7AitxGa6wik1, line 2 character 208

This is because 'class' word in JS is not allowed as class property. You should add apostrophes around properties.

3 Answers, 1 is accepted

Sort by
0
sven
Top achievements
Rank 1
answered on 18 Sep 2012, 04:19 PM
I have the same problem. Did someone know a fix to solve this issue?
0
Mariano
Top achievements
Rank 1
answered on 13 Nov 2012, 05:56 PM
I 've solved this using uppercase for the word class.
Instead of 
 .HtmlAttributes(new { @class = "gridColumnPrice" })

I use:  .HtmlAttributes(new { @CLASS = "gridColumnPrice" })
In javascript it is no longer recognized as the reserved word 'class', and for html its the same.
Hope it will be usefull for someone!
0
AspenSquare
Top achievements
Rank 1
answered on 14 Nov 2012, 09:28 PM
Thank you!
Tags
Grid
Asked by
Marek
Top achievements
Rank 1
Answers by
sven
Top achievements
Rank 1
Mariano
Top achievements
Rank 1
AspenSquare
Top achievements
Rank 1
Share this question
or