2016-03-08 40 views
1

所以,我想要做的是syncronously讓我的公式WYSIWYGish輸入元素如何在MathQuill 0.10中同步文本字段和公式字段內容?

<span id="editable-math" class="mathquill-editable"></span> 

和LaTeX輸入元素

<textarea id="mathjaxSrc" rows="6" cols="60"></textarea> 

工作。我的代碼是

var MQ = MathQuill.getInterface(2); 
var mathField = MQ.MathField(latexMath, { 
    spaceBehavesLikeTab: true, 
    handlers: { 
     edit: function() { 
      latexSource.value = mathField.latex(); 
      jQuery(latexSource).change(); 
     } 
    } 
}); 
jQuery(latexSource).change(function(){ 
    mathField.latex(latexSource.value); 
}); 

這主要作品:WYSIWYGish編輯器更新乳膠輸入字段,但只有LaTeX的輸入字段更新WYSIWYGish編輯鼠標點擊之後在其他地方(可能是在模糊)。

我的問題是:如何使WYSIWYGish編輯器的值更新而無需點擊其他地方?我猜想要怎麼補充.change處理程序?

回答

1

好的,沒關係,它不是關於MathQuill,而是關於使用什麼事件處理程序。此行爲是changedocumented behaviour。爲了實現我所需要的,我必須使用​​或keyupkeypress方法(使用或不使用jQuery)。

相關問題