如何使用淘汰赛禁用点击事件? [英] How to disable click event using Knockout?
问题描述
我有两个按钮,叫做
<a href='#' data-bind='click: clickActivateSpatialSearch' id='draw_polygon'>
<a href='#' data-bind='click: clickActivateSpatialSearchBox' id='draw_box'>
这里最好的是什么?我可以在$(document).ready
上使用jQuery吗?问题是数据绑定单击在被按下时会禁用另一个单击事件,并且同样如此.但是当我按下相同的按钮时,它将再次启用第二个按钮.
What will be the best here? Can I use jQuery on $(document).ready
? The problem is data-bind click disables the other click event when being pressed and likewise. But when I press same button, it enables the second button back once again.
所以我要说的是所有的胡言乱语,我只希望一次启用一个按钮.这可能与淘汰赛同时进行吗?如果是这样,请告诉我如何. PS:我已经在淘汰赛网站上查看了关于启用的信息,但是我不明白.我应该如何使其充分发挥作用?
So what I'm trying to say with all jibberish is that, I only want one button enabled at a time. Is this possible to coop together with knockout? And if so please tell me how. PS: I have looked on the knockout site about enable, but I do not get it. How I should get it to work fully?
推荐答案
您可以添加一个观察对象,其中包含按下了哪个按钮,然后将单击更改为检查该观察对象的函数:
You could add an observable that held which button was pressed then change the click to be a function that checked the observable:
<a href='#' data-bind='click: function() {
if(buttonClickedObservable() == 'polygon')
{
clickActivateSpatialSearch();
}' id='draw_polygon'>
<a href='#' data-bind='click: function() {
if(buttonClickedObservable() == 'box')
{
clickActivateSpatialSearchBox'();
}' id='draw_box'>
您将不得不决定如何设置可观察的物体.
You would have to decide how you set the observable though.
这篇关于如何使用淘汰赛禁用点击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!