admin管理员组文章数量:1291214
C# allows a reserved word to be used as a property name via the at sign. e.g.
// In ASP.NET MVC, we use @class to define
// the css class attribute for some HtmlHelper methods.
var htmlObject = new { readonly = "readonly", @class = "ui-state-highlight" }
I want to do the same in JavaScript. e.g.
function makeGrid(grid, pager) {
grid.jqGrid({
caption: 'Configurations',
colNames: ['Id', 'Name'],
colModel: [
{ name: 'Id', index: 'Id' },
{ name: 'Name', index: 'Name', editable: true,
editoptions: { readonly: 'readonly', class: 'FormElement readonly' } },
],
pager: pager,
url: 'www.example/app/configurations") %>',
editurl: 'www.example/app/configurations/edit") %>'
}).navGrid(pager, { edit: true, add: false, del: false, search: false }, {}, {}, {});
}
Note class: 'FormElement readonly' is supposed to set the css class value on jqGrid's edit dialog, but IE errors out on the reserved word.
Is there an escape character in JavaScript too? #class? @class? &class? Otherwise, how might I tell jqGrid to set the css class on the popup editor? Thank you.
C# allows a reserved word to be used as a property name via the at sign. e.g.
// In ASP.NET MVC, we use @class to define
// the css class attribute for some HtmlHelper methods.
var htmlObject = new { readonly = "readonly", @class = "ui-state-highlight" }
I want to do the same in JavaScript. e.g.
function makeGrid(grid, pager) {
grid.jqGrid({
caption: 'Configurations',
colNames: ['Id', 'Name'],
colModel: [
{ name: 'Id', index: 'Id' },
{ name: 'Name', index: 'Name', editable: true,
editoptions: { readonly: 'readonly', class: 'FormElement readonly' } },
],
pager: pager,
url: 'www.example./app/configurations") %>',
editurl: 'www.example./app/configurations/edit") %>'
}).navGrid(pager, { edit: true, add: false, del: false, search: false }, {}, {}, {});
}
Note class: 'FormElement readonly' is supposed to set the css class value on jqGrid's edit dialog, but IE errors out on the reserved word.
Is there an escape character in JavaScript too? #class? @class? &class? Otherwise, how might I tell jqGrid to set the css class on the popup editor? Thank you.
Share Improve this question edited May 23, 2017 at 12:12 CommunityBot 11 silver badge asked May 26, 2010 at 5:38 Robert ClaypoolRobert Claypool 4,3129 gold badges53 silver badges61 bronze badges 1- Btw., '@' is not an ampersand, '&' is an ampersand (in the first paragraph). – Boris B. Commented Apr 19, 2012 at 13:31
4 Answers
Reset to default 10I think in this context, quoting class should work as it's the name of a property on an object literal i.e.
editoptions: { readonly: 'readonly', 'class': 'FormElement readonly' } },
I dont know jqGrid but I would imagine 'class' would work.
Use "className".
You can also use @class in jQuery
版权声明:本文标题:asp.net mvc - How to "escape" the JavaScript class keyword to specify a CSS class value - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741519489a2383095.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论