How do I use X-editable on dynamic fields in a Meteor template now with Blaze?

前端 未结 6 2092
忘了有多久
忘了有多久 2021-01-01 05:42

I had x-editable working in Meteor 0.7.2 but since upgrading to 0.8.0 it no longer renders correctly. I tend to end up with a bunch of Empty tags. This is frustrating becaus

6条回答
  •  春和景丽
    2021-01-01 05:53

    Working off of Andrew's answer, I was able to get this to work for me. It's not in coffeescript, also I think the Blaze.getCurrentData() might now be Blaze.getData() as per the Meteor docs.

    Template:

    
    

    Code:

    Template.objective.rendered = function(){
        var self = this;
        this.autorun(function(){
            data = Blaze.getData();
            self.$("#objective.editable").editable("destroy").editable({
                placement: "bottom",
                display: function(){},
                success: function(response, newValue){
                    var insert = {
                        "contract_id":data._id,
                        "value": newValue
                    };
                    Meteor.call('update_objective', insert);
                }
            });
        });
    };
    

    There are probably improvements I can make and I'm happy to hear them, but I spent a lot of time dealing with bad coffeescript translation (kept telling me to use return all the time), so I wanted to add another example.

提交回复
热议问题