标记它!连续预览刷新,无需按回车键
我正在使用 MarkItUp (http://markitup.jaysalvat.com/) 并且无法真正理解了解如何让它在键入每个字符时(甚至遇到“空格”时)持续更新预览窗格。默认情况下,仅当按下 Enter 键时才会刷新预览窗格。
有什么方法可以自定义这种行为吗?文档提到了一个 previewAutoRefresh
键,但设置它会导致输入时更新,而不是更快。
谢谢!
I'm using MarkItUp (http://markitup.jaysalvat.com/) and can't really figure out how to get it to continuously update the preview pane as each character is typed (or even when a 'space' is encountered). By default it refreshes the preview pane only when the enter key is hit.
Is there any way to customize this behavior? The documentation mentions a previewAutoRefresh
key, but setting it results in the update-on-enter thing, not any faster.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用与此问题中相同的技术。
请注意,这将在每次按键时向您的网络服务器发送一个新请求,因此如果您有很多用户,这将是很多点击。
Use the same technique as in this question.
Note that this will send a new request to your webserver on every keypress, so if you have a lot of users, this'll be a lot of hits.
很晚了,但更好的解决方案是为每个按键启动一个计时器(1 秒),以便在用户暂停时只进行一次预览(此代码片段使用了 JQuery 计时器插件):
有关更多详细信息,您可以查看关于轮子编码的优秀帖子 语法突出显示谈论文本区域预览。
Very late but a better solution is to start a timer (1 sec) for each keypress so that the preview is done only once, when the user do a pause (this code snippet used JQuery timer plugin):
For more detail you can see the excellent post on coding the wheel Syntax highlighting talking about textarea preview.
默认情况下,预览自动刷新处于启用状态。
任何标记插入(或按下 Enter 键)时都会刷新预览。
预览的内容由 ajax 发送到服务器端解析器以呈现标记语言(textile、markdown、bbcode 等)。每次击键都执行此操作几乎是不可能的(又慢又重)。
标记起来!内置预览只是一个帮手。您可以禁用它并使用客户端脚本(例如 Showdown)编写自己的预览代码,就像处理常规文本区域一样。
:)
previewAutoRefresh is on by default.
The preview is refreshed at any markup insertion (or Enter key pressed).
The content of the preview is sent by ajax to a server side parser to render the markup language (textile, markdown, bbcode etc). Doing this operation on every key stroke is almost impossible (slow and heavy).
The markItUp! built-in preview is just a helper. You can disable it and code your own preview, using a client side script (Showdown for example) as you would have to do with a regular textarea.
:)