songjun
2024-09-05 a3302fda10ff21ed3700be462ad560163ca13f14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
@{
    ViewBag.Title = "前台管理";
    Layout = "~/Views/Shared/Master.cshtml";
}
<script>
    var viewModel;
    $(function () {
        viewModel = new myViewModel_Menus(@Html.Raw(Json.Encode(Model)));
        ko.applyBindings(viewModel, $(".container")[0]);
    })
    function myViewModel_Menus(data)
    {
        var self = this;      
        ko.mapping.fromJS(data, mapping, self)
    }
    var mapping = {
        'MenusList': {
            create: function (options) {
                return new MenusList(options.data);
            }
        }
    }
    function MenusList(data) {
        console.log(data)
        var self = this;
        self.Detailed = function () {
          
            window.location.href = "@Url.Action("ViewDetailed", "Backstage")" + "?MenuId=" + self.Id();
        }
        ko.mapping.fromJS(data, {}, self)
 
    }
</script>
<div class="container">
    <div class="row" style="border-bottom:solid #ebe6e6">
        <p> 质评系统 >> 前台管理 </p>
    </div>
    <div class="row">
        
            <table class="table table-bordered">
              
                <thead>
                    <tr style="background:#0094ff">
                        <th style="text-align:center">菜单</th>
                        <th style="text-align:center">操作</th>
                     
                    </tr>
                </thead>
                <tbody data-bind="foreach:MenusList">
                    <tr>
                        <td style="text-align:center" data-bind="text:Name"></td>
                        <td style="text-align:center">
                            <span>
                                <button type="button" class="btn btn-info  btn-xs" data-bind="click:Detailed">
                                    查看
                                </button>
                            </span>
                        </td>
 
                    </tr>
                </tbody>
            </table>
        </div>
 </div>