mytest.js
odoo.define('base_phone_popup_mytest', function(require){
"use strict";
var core = require('web.core');
var AbstractAction = require('web.AbstractAction');
var mv = "";
var Mytest = AbstractAction.extend({
//render your template
template: "base.phone.popup.mytest",
xmlDependencies: ['./base_phone_popup/static/src/xml/mytest.xml'],
//initialize
init: function(parent) {
var self = this;
console.log(" mytest.js -> init " + arguments[1].context['myvalue']);
mv = arguments[1].context['myvalue'];
this._super.apply(this, arguments);
},
//Binding Events
events : {},
});
core.action_registry.add('base.phone.popup.mytest', Mytest);
return {'mytest': Mytest};
});
mytest.xml
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="base.phone.popup.mytest">
<div class="o_mytest">
<input type="text" id="id_mv" class="o_mv form-control" />
</div>
</t>
</templates>
一些 template.xml
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template id="assets_backend" name="base_phone_popup assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/scss" href="/base_phone_popup/static/src/scss/mytest.scss"/>
<script type="text/javascript" src="/base_phone_popup/static/src/js/mytest.js"/>
</xpath>
</template>
</data>
</openerp>
mytest.scss
.modal.o_technical_modal {
.modal-content {
border-radius: 0;
width: 435px;
height: 700px;
}
}
.o_mytest {
position: relative;
display: block;
width: 400px;
height: 600px;
border: 1px solid blue;
background: #AFA;
font-size: 64px;
}
.o_mv {
height:66px;
font-size:64px;strong text
font-weight:bold;
}
问题:如何将var mv放置为输入o_mv的初始值?
在我的情况下,Myvalue是来自星号服务器的一些异步数据。
GetElementByID()在加载DOM之前不起作用,在事件函数中起作用。也许,我需要修改
功能render(),但找不到工作示例。
答案 0 :(得分:0)
我找到了工作样本。
start: function(parent) {
var self = this;
this._super.apply(this, arguments);
self.$('.o_mv').val(mv);
},
此代码将初始值mv设置为类别为o_mv的html页面标签。 就我而言,这是:
<input type="text" id="id_mv" class="o_mv form-control" />