2016-03-29 14 views
3

Kullanıcının benim hakkımdaki alanını ayarlamak için froala: editor-reactive paketini kullanan Meteor projem var. Değer değişiklikleri (umarım) olarak kaydetmek içinMeteor froala: Verilerin değiştirilmesinde editör-reaktif kaydetme

<template name="profile"> 
    <div> 
    {{> froalaReactive _onbeforeSave=doSave _value=getAbout}} 
    </div> 
</template> 

gerekiyordu:

Template.profile.helpers({ 
    getAbout: function() { 
    return Meteor.user().profile.about; 
    }, 
    doSave: function (e, editor) {   
    // Get edited HTML from Froala-Editor 
    var newHTML = editor.getHTML(); 
    // Do something to update the edited value provided by the Froala-Editor plugin, if it has changed: 
    if (!_.isEqual(newHTML, Meteor.user().profile.about)) { 
     Meteor.call("updateTestimony", Meteor.userId(), newHTML); 
    } 
    return false; // Stop Froala Editor from POSTing to the Save URL 
    } 
} 

İşte benim şablon html kodu:

İşte benim şablon js kodudur. Ancak var newHTML = editor.getHTML(); numaralı satırda bir hatam var ve ayrıca var newHTML = editor.html.get(true); numaralı telefonu denedim. Her ikisi de html veya getHTML özelliğini okuyamayacağı bir hatayla sonuçlanır. Bunun sadece bir yazım hatası olduğunu umuyorum ve başka bir şeye ihtiyacım var ama burada neyin var?

cevap

0

Per the plugin docs, deneyin:

var newHTML = editor.html.get(true /* keep_markers */); 

Bu işe yaramazsa, muhtemelen farklı bir sürümünü kullanıyor olabilirsiniz. Bu durumda, aşağıdaki sözdiziminden denemek: Resmi dokümanlar here den

var newHTML = $('.your_selector').editable('getHTML', true, true); 

var newHTML = $('.your_selector').froalaEditor('html.get', true); 

Daha this question bakın.