我想在某些案例中添加创建操作,但我不知道正确的语法。
<script type="text/javascript">
$(document).ready(function () {
$('#XXX').jtable({
title: 'XXXXX',
actions: {
listAction: '@Url.Action("XXX")',
createAction: '@Url.Action("XX","XXX")',
deleteAction: '@Url.Action("XX", "XXX")',
updateAction: '@Url.Action("XX", "XX")'
},
fields: {
Id: {
key: true,
create: false,
edit: false,
list: false
},
Name: {
title: 'Ad',
width: '40%',
inputClass: 'validate[required]'
}
}
});
$('#XXXX').jtable('load');
});
我的意思如下: 如果用户有权限,我想添加创建操作。
actions: {
listAction: '@Url.Action("XXX")',
@if(true){ createAction: '@Url.Action("XX","XXX")',}
deleteAction: '@Url.Action("XX", "XXX")',
updateAction: '@Url.Action("XX", "XX")'
}
谢谢。
答案 0 :(得分:1)
基于this post,以下内容对我有用:
@if(true){
<text>
createAction: '@Url.Action("XX","XXX")',
</text>
}