我试图在集合中找到一个属性等于html选择选项值的模型.
<div id="hospital-details">
<select name="hospitalnames">
<option><%- model.get('name') %></option>
</select>
</div>
Run Code Online (Sandbox Code Playgroud)
每当更改医院名称时,触发jquery更改回调以查找具有所选选项值作为属性值的locationModel,如下所示,
$('select[name="hospitalnames"]').change(function() {
var name = $(this).val();
locationListCollection.each(function(locationModel) {
if ($.trim(locationModel.get('name')) == $.trim(name)) {
that.locationModel = locationModel;
return false; // control is returned to underscore.min.js
}
});
});
console.log(that.locationModel); // this is not being displayed at all
Run Code Online (Sandbox Code Playgroud)
找到具有属性的locationModel后,我无法退出循环.有帮助吗?此刻我已经调查了 这一点但没有成功.
我正在尝试编写一个简单的方法(任何语言),它给出了6个最低有效数字.
method giveSD(n) {
return 6 least significant number;
}
Run Code Online (Sandbox Code Playgroud)
例如,如果n是1963222,则该方法应返回963222.