Last active
March 24, 2017 16:11
-
-
Save billdami/cadfb80d7c90df98353cc3d9900f2b73 to your computer and use it in GitHub Desktop.
MathJax Rendering Issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
mathjax: Ember.inject.service(), | |
tagName: 'span', | |
didRender() { | |
this.get('element').innerHTML = this.get('content') || ''; | |
if(!Ember.isBlank(this.get('content'))) { | |
this.get('mathjax').rerender(); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember/MathJax Rendering Issue', | |
actions: { | |
updateContent: function() { | |
this.set('content', this.get('newContent')); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Service.extend({ | |
rerender() { | |
Ember.run.scheduleOnce('afterRender', this, 'renderFormulas'); | |
}, | |
renderFormulas(element) { | |
if(window.MathJax) { | |
MathJax.Hub.Queue(["Typeset", MathJax.Hub, element]); | |
} | |
}, | |
destroyFormulas(element) { | |
if(window.MathJax) { | |
const formulas = MathJax.Hub.getAllJax(element); | |
formulas.forEach((formula) => { | |
Ember.$(formula.SourceElement()).remove(); | |
formula.Remove(); | |
}); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.11.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.6.2", | |
"ember-data": "2.11.0", | |
"ember-template-compiler": "2.6.2", | |
"ember-testing": "2.6.2", | |
"mathjax": "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment