gpt4 book ai didi

javascript - Summernote:手动打开链接对话框

转载 作者:行者123 更新时间:2023-12-02 23:52:10 27 4
gpt4 key购买 nike

我正在尝试编写一个脚本,当我单击按钮时,该脚本会自动显示 Summernote 链接对话框。

例如,我有以下按钮:

<button class="btn btn-sm btn-info use_hyperlink" data-href="//files.examples.org.uk/song.mp3" type="button">Copy</button>

所以在我的 js 中我有:

$("#linklist").on("click", "button.use_hyperlink", function () {
var href = $(this).data("href")
modal = $("div.note-editor.note-frame.panel.panel-default div.modal.link-dialog")
modal.addClass("in").modal("show")
modal.find("input.note-link-url.form-control.note-form-control.note-input").val(href)
modal.find("button.note-btn.note-btn-primary.note-link-btn").prop("disabled", false).removeClass("disabled").attr("type","button")
})

这将打开对话框,成功粘贴 href但点击Insert Link按钮提交 Summernote 所在的表单。

查看summernote code在线 6765有一个函数叫showLinkDialog我想这就是我想要的。但是当我尝试时:

$(document).ready(function () {
$("textarea#summernote").summernote({height: 500});
$("#linklist").on("click", "button.use_hyperlink", function () {
var href = $(this).data("href")
$("textarea#summernote").showLinkDialog({
url: href
});
})
})

我得到一个Uncaught TypeError: $(...).showLinkDialog is not a function

最佳答案

尝试触发单击按钮

$('.note-insert [aria-label^="Link"').trigger('click')

关于javascript - Summernote:手动打开链接对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55594180/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com