[英]How to insert value from jquery into knockout data-bind line?
The problem occurred while trying to insert new parameter into url property, which is inside select2. 尝试将新参数插入到select2内部的url属性中时发生了问题。
<span><input type="hidden" class="expanded"
data-bind="
select2ex:
{url: '(CONTROLLER_NAME)/(METHOD_NAME)?type=some_type&DocDate=PROBLEM!',
value: ID,
text: NAME,
options:{
minimumInputLength: 1,
ajax: {
params: {
headerErrorsContainer: '#editor .errors-placeholder'
},
cache: true}
},
select2InterfacePropName: 'SomeSelect2'}
"
style="width: 100%"></input></span>
So how to get value from jquery into (PROBLEM!) place? 那么如何从jquery中获取价值到(问题!)位置呢?
Maybe it's possible to some string interpolation? 也许可以进行一些字符串插值?
...&DocDate={jquery call?}
You could try using a computed by assigning it to url parameter: 您可以尝试通过将计算值分配给url参数来使用它:
...
url: myComputed,
...
self.myComputed = ko.pureComputed(() => {
var type = 'sometype';
var docDate = 'mydate';
return `(CONTROLLER_NAME)/(METHOD_NAME)?type=${type}&DocDate=${docDate}`; //string interpolation
}, self);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.