Reputation: 145
Ive created a button named update
in the frontend.
I need to run the function that I wrote in the python file while clicking the button using jquery.
xml:
<t>
<button id="update_health_profile_front"
class="btn btn-primary"
type="button">Update
</button>
</t>
py:
@api.multi
def update_health_profile(self):
# partner = self.partner_id
#some_method
js:
$('#update_health_profile_front').click(function(event){
var rpc = require('web.rpc');
rpc.query({
model: 'health.profile',
method: 'update_health_profile',
})
.then(function(result){
for (i= 0; i< result.length; i++){
console.log("result",result[i]);
}
},);
Its not working and I don't think this is the right way either, Can anybody share some knowledge?
Upvotes: 0
Views: 648
Reputation: 2721
Well you can try this, I think it should work.
$('#update_health_profile_front').click(function(event){
var rpc = require('web.rpc');
rpc.query({
model: 'this.name',
method: 'update_health_profile'
})
.then(function(result){
for (i= 0; i< result.length; i++){
console.log("result",result[i]);
}
},);
Upvotes: 1