在链接按钮中将模型作为参数传递,使用KO单击 [英] Passing the model as argument in the link button click using KO

查看:89
本文介绍了在链接按钮中将模型作为参数传递,使用KO单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的示例中,我需要在链接按钮单击(列表,范围)中将模型作为参数传递.如何做到这一点

In this below example I need to pass the model as argument in the link button click (List, range) . how to acheive this

<div data-bind = "foreach:modelList" >
        <div class="BDCRQuery">
            <div class= "Body" > 
                <div>
                    <select id ="SELECT" data-bind="options: Attributes, optionsText: 'AttributeName', optionsValue: 'Id', optionsCaption: 'Select Attribute...',value : SelectedAttribute"></select>
                </div>
                <div>
                    <span>with any of the following values:</span>
                </div>
                <div class="option">
                    <a href="#"  id = "List" class="link">List</a> | <a href="#"  id= "Range" class="link">Range</a>
                </div>
               </div>
    </div>
</div>             

推荐答案

使用$ parent和bind关键字

luse the $parent and bind keywords

<a data-bind="click: $parent.functionName.bind($parent)" />

$ parent将指向持有modelList数组的对象,它将调用一个名为functionName的函数,bind将确保this关键字是正确的上下文.该函数将单击该项目作为参数

$parent will point to the object holding the array of modelList and it will call a function called functionName, bind will ensure that the this keyword is the correct context. The function will have the item clicked as the argument

这篇关于在链接按钮中将模型作为参数传递,使用KO单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆