跳至内容
菜单
此问题已终结
2 回复
9160 查看


Using JS, the field in the view is updated, but pressing the save button does, not save the value in the field.

JS code:

var FormController = require('web.FormController');
FormController.include(
{
_onButtonClicked: function (event)
{
if(event.data.attrs.id === "action_addpoint")
{
$("input[name='points'].o_input_points")
.val("save_a_modified_field_with_JS")
.focus()
.change();
}
},
});

XML Code:

<header>
<button id="action_addpoint" string="Add point"/>
</header>
<group col="4">
<field name="points" class="points"/>
</group>



形象
丢弃
编写者 最佳答案

I cannot use it like this, when saving the record ... the modified information is not saved, in that field.
I guess due to the lack of user interaction

形象
丢弃
最佳答案

Hi,

i think your code is not executed. you need to write that JS code in static js using script function in form.

You can do something like:

<field name="arch" type="xml">

<form>

<script type="text/javascript">


$(document).ready(function() {

    //DOM manipulation code

});

<!-- can write fields and header or anything here -->

</script>

</form>

</field>

形象
丢弃
相关帖文 回复 查看 活动
2
1月 20
5752
1
6月 23
1966
1
5月 23
1942
1
10月 22
4095
5
12月 24
33179