我有一个修改后的 pagedown markdown 标记脚本,用于将图像 url 插入编辑器,但它仅在第一次起作用。
我已经用注释解释了我的代码
</script>
<script type="text/javascript">
(function () {
var converter = new Markdown.Converter();
var help = function () { window.open('http://mywebsite.com/editing-help'); }
var editor = new Markdown.Editor(converter);
editor.hooks.set('insertImageDialog', function(callback) {
setTimeout(function ()
{
//i use bootstrap dialog to enter the url
$('#fileModal').modal('show');
/*i have a button for clearing the textbox when i open
it the second time since when i open it the second
time the modal still contains what i had placed previously*/
$("#clear").on("click", function(e) {
e.preventDefault();
$("#imgt").val('');
$("#file").val('');
});
//the button that when clicked inserts the image url
$("#insert_image_post").on("click", function(e) {
e.preventDefault();
//the image file being inserted
if($("#imgt").val().length > 0)
{
var $url = $('input[type=text]');
var image = $("#imgt").val();
callback(image);
$("#fileModal").modal('hide');
}
});
}, 0);
return true; // tell the editor that we'll take care of getting the image url
});
editor.run();
})();
</script>
任何人都有 pagedown markdown javascript...想法来帮助我理解我哪里出错了?
我设法让它发挥作用
就像markdown编辑器运行不流畅一样.on("click", function(e)...
就我而言。 IE。
$("#insert_image_post").on("click", function(e) {
e.preventDefault();
所以我在经历了他们的之后使用了他们的Markdown.Editor.js
文件即
var thebtn = document.getElementById("insert_image_post");
thebtn.onclick = function () {
下面是完整调整后的代码
<script>
(function () {
var converter = new Markdown.Converter();
var help = function () { window.open('http://stackoverflow.com/editing-help'); }
var editor = new Markdown.Editor(converter);
editor.hooks.set("insertImageDialog", function (callback) {
$('#fileModal').modal('show');
var thebtn = document.getElementById("insert_image_post");
thebtn.onclick = function () {
var images = $(".img-url").val();
callback(images)
$('#fileModal').modal('hide');
};
var theclear = document.getElementById("clear");
theclear.onclick = function () {
$("#imgt").val('');
$("#file").val('');
};
return true; // tell the editor that we'll take care of getting the image url
});
editor.run();
})();
</script>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)