12

我需要将 url 参数连接到锚标记上。我将如何将其插入以下模板?

        <tbody data-bind="foreach: Customers">
            <tr class="rowEven">
                <td data-bind="text: Name"></td>
                <td data-bind="text: CustomerType"></td>
                <td><a href="customers.aspx?customer=[CustomerAccountIDHere]">Manage</a><a href="#">Guest Admin</a></td>
            </tr>
        </tbody>

我试过这不会运气:

            <tr class="rowEven">
                <td data-bind="text: Name"></td>
                <td data-bind="text: CustomerType"></td>
                <td><a data-bind="attr: { href: 'customers.aspx?customer=' + CustomerAccount_BID}">Manage</a><a href="#">Guest Admin</a></td>
            </tr>
4

3 回答 3

14

我认为视图模型可能是问题所在,这是一个工作示例:http: //jsfiddle.net/L4hUq

于 2012-08-18T04:18:44.403 回答
10

添加“()”- CustomerAccount_BID()对我有用。

于 2014-02-20T06:39:31.127 回答
0

尝试这样的事情......

$(function()
{

    var myViewModel1 = function () {
        var self = this;
        self.firstName = ko.observable("Kamalakar");
        self.lastName = ko.observable("Ashtankar");
        self.fullName = ko.pureComputed(function () {
            return self.firstName() + " " + self.lastName();
        }
        );
    };

    ko.applyBindings(myViewModel1);

});
于 2016-06-12T11:15:49.760 回答