使用“更新的 WMD 编辑器” 在 AJAX 表单加载的文本区域中
我们正在尝试使用 Stackoverflow 优秀的 WMD / Markdown 编辑器 (http://blog.stackoverflow.com /2009/01/updated-wmd-editor/,http://github.com/2009/01/updated-wmd-editor/ com/derobins/wmd/tree/master)在 Symfony 项目上。
这在不涉及任何 AJAX 的文本区域上效果很好。 但是,当我们必须首先包含 wmd.js,然后在用户交互(即“单击链接”)中通过 AJAX 加载文本区域时,我们完全无法使 WMD 工作,Firebug 给我们
elem is null
addEvent()()wmd.js (Linie 110)
setupEvents()()wmd.js (Linie 1790)
init()()wmd.js (Linie 1970)
previewManager()()wmd.js (Linie 1987)
loadListener()()wmd.js (Linie 1763)
[Break on this error] if (elem.attachEvent) {
加载页面(即之前文本区域加载)。
Symfony 的 AJAX 加载器似乎 eval() 标签之间的所有内容。 我们尝试将整个脚本直接包含在这些标签之间,我们尝试转义这个和那个,但没有成功,出现了不同的错误。
此时我们认为我们必须将脚本包含在普通页面中,并且在 AJAX 调用之后我们必须手动启动 WMD - 我们必须调用哪些函数? 我们是否完全偏离了轨道,需要使用不同的方法?
谢谢你!
We're trying to use Stackoverflow's excellent WMD / Markdown editor (http://blog.stackoverflow.com/2009/01/updated-wmd-editor/, http://github.com/derobins/wmd/tree/master) on a Symfony project.
This works excellent on textareas without any AJAX involved. But when we have to include wmd.js first, and then later on user interaction (i.e. "click on link") have the textarea loaded via AJAX we utterly fail to make WMD work, Firebug is giving us
elem is null
addEvent()()wmd.js (Linie 110)
setupEvents()()wmd.js (Linie 1790)
init()()wmd.js (Linie 1970)
previewManager()()wmd.js (Linie 1987)
loadListener()()wmd.js (Linie 1763)
[Break on this error] if (elem.attachEvent) {
on loading the page (i.e. before textarea loading).
Symfony's AJAX Loader seems to eval() everything between tags. We tried including the whole script directly between those tags, we tried escaping this and that, but had no success with differnt errors coming up.
At this point we think we have to include the script in the normal page and after the AJAX call we have to initiate WMD manually - what functions do we have to call? Are we completely off track and need to use a different approach?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以使用我的版本。 只需将构造函数调用、配置值以及对 start() 方法的调用放入处理从 AJAX 请求获取的结果的回调函数中即可。 我的 mooWMD 版本。
You can use my version. Simply put the constructor call, config values and the call to the start() method in the callback function that handles the results you get from the AJAX request. My version of mooWMD.
github 上的 wmd 的 drobins 分支也正在解决 AJAX 问题。
drobins fork of wmd on github is solving the AJAX issues as well.
我遇到了同样的问题,一旦我的文本区域被异步添加到页面,我就会初始化 WMD。
这是我的代码:
I had this same issue and I initialize WMD once my textarea has been added to the page asynchronously.
Heres my code: