admin管理员组文章数量:1356582
I'm using bootstrap-date-picker with Vue.js 2. Bootstrap datepicker doesn't update the model.
But if I use the following script, I cannot access the scope to use this
loadFormProps() {
// init other stuff
$('#founding_date').change(function() {
this.founding_date = $(this).val();
});
}
Modal is as following:
data() {
return {
founding_date: '01 - 01 - 2017',
}
};
What will be the best solution for this, as I cannot get vm.$data
working, and I cannot access this
within the function.
I'm using bootstrap-date-picker with Vue.js 2. Bootstrap datepicker doesn't update the model.
But if I use the following script, I cannot access the scope to use this
loadFormProps() {
// init other stuff
$('#founding_date').change(function() {
this.founding_date = $(this).val();
});
}
Modal is as following:
data() {
return {
founding_date: '01 - 01 - 2017',
}
};
What will be the best solution for this, as I cannot get vm.$data
working, and I cannot access this
within the function.
-
You have two
this
inside thechange
callback function. Whichthis
is not accessible? What is the console error message? What should the firstthis
refer to? – gus27 Commented Jan 23, 2017 at 11:06
1 Answer
Reset to default 8You have to save the this
inside some other var
before the onchange
JS block:
loadFormProps() {
// init other stuff
var that = this
$('#founding_date').change(function() {
that.founding_date = $(this).val();
});
}
本文标签: javascriptUpdate data value with Vue from jQuery onChangeStack Overflow
版权声明:本文标题:javascript - Update data value with Vue from jQuery onChange - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744061589a2584223.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论