[英]How Can I stop ParentNode from getting called recursively everytime I trigger the event listener?
[英]Subscribe event not getting called everytime
我有搜索屏幕,当用户导航到结果页面时,结果页面上有带有值(分钟,字符)的单选按钮。
我已经在结果页面上订阅了单选按钮单击事件,每当用户单击单选按钮订阅功能时,都应该调用该事件。
现在的问题是:
1)当用户第一次点击搜索按钮时,显示结果。
2)用户选择“分钟”单选按钮,订阅事件被调用并开始工作。
3)用户选择返回按钮,并且用户被重定向到搜索屏幕。
4)用户点击搜索按钮,结果显示。
5)用户试图单击“字符”按钮,没有调用订阅事件。
她的是我的代码:
<div class="nmc-righttab" style="width: 60%">
<div class="nmc-righttab" style="margin-left:20px">
<label class="nmc-label" style="line-height:21px">@Res.Trends.DisplayResultBy</label>
</div>
<div class="nmc-righttab" style="width:250px">
<div class="nmc-lefttab" style="margin-left:5px">
<input type="radio" id="MinuRadio" name="GphInterval" value="2" data-bind="checked:GraphClick" />
</div>
<div class="nmc-righttab">
<label class="nmc-label" for="MinuRadio" style="line-height:21px">@Res.Trends.Minutes</label>
</div>
<div class="nmc-lefttab" style="margin-left:5px">
<input type="radio" id="CharRadio" name="GphInterval" value="3" data-bind="checked:GraphClick" />
</div>
<div class="nmc-righttab">
<label class="nmc-label" for="CharRadio" style="line-height:21px">@Res.Trends.Characters</label>
</div>
</div></div>
JS代码:
this.GraphClick.subscribe(function (val) {
model.showGraphResults(true);
model.GraphIntervalSelected(val);
searchSpeechGraphView(speechUsage);
}, this)
与其将this
参数作为参数传递给subscribe
方法,不如将其与this
对象绑定在一起。 像这样
JS代码:
this.GraphClick.subscribe(function (val) {
model.showGraphResults(true);
model.GraphIntervalSelected(val);
searchSpeechGraphView(speechUsage);
}.bind(this));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.