gpt4 book ai didi

javascript - Ember JS : Value assigned through JQuery or JavaScript not reflected in model

转载 作者:行者123 更新时间:2023-11-27 22:47:49 25 4
gpt4 key购买 nike

I'v working on EmberJS app and facing this very tricky problem:

我已将 JSON 对象绑定(bind)到表单,当通过键盘输入值时工作正常,但如果通过 JQuery 分配的值已成功输入并显示,但该值不会反射(reflect)在 JSON 对象中。

JSON 对象:

var obj = {
ctry_id: "",
ctryl_name: "",
};

Ember 路线:

setupController: function (controller, model) {
controller.set('obj', obj);

},

HandelBar View :

{{input id="ctryl_name" type="text"  value=ctryl_name name="ctryl_name"  class="form-control" }}

jQuery:

$('#ctryl_name').val('text valu');

最佳答案

我遇到过这个问题并用 Ember.set 修复了:

var ctryl_name  = $('#ctryl_name').val(); //get text box value

Ember.set(obj, "ctryl_name", ctryl_name); //set ember object value

希望对你有帮助:)

关于javascript - Ember JS : Value assigned through JQuery or JavaScript not reflected in model,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38291358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com