繁体   English   中英

聚合物中铁形式的ajax响应后更新UI

[英]Update UI after ajax response for iron-form in Polymer

我有一个ajax请求没有更新UI的问题。 我需要手动刷新页面。

基本上,这是一个类似按钮。 按下时,应该增加点赞的次数。 HTTP请求和响应运行正常。 但是值{{commentaire.likes}}不会立即更新。

<template>
    <form is="iron-form" id="likeForm" method="post" action="/like/{{commentaire.heure}}" on-click="submitLike" on-iron-form-response="augmenterLikes">
        <paper-button raised>{{commentaire.likes}} J'aime</paper-button>        
    </form>

</template>

<script>


    Polymer({

        is: 'my-comment',
        properties: {
            commentaire : {
                type: Object,
                value: {},                  
            },
        }, 

        augmenterLikes: function(e) {
            this.commentaire.likes = e.detail.response;
        },



    });

任何帮助,将不胜感激。

为了更新深层属性,您必须使用set方法,例如,在您的情况下:

this.set('commentaire.likes', e.detail.response);

我在这里使用随机数生成器制作了一个示例: https : //jsfiddle.net/fLbf6uag/1/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM