jquery - 使用 jquery 拖放电子邮件模板生成器
问题描述
我想创建拖放电子邮件模板生成器。我尝试了下面的代码但没有工作。我想在拖入右侧框后编辑文本编辑器
点击这里查看我的代码
JS
$( function() {
$('.clickedit').hide();
$("#dragme").draggable({
helper: 'clone',
cursor: 'move',
tolerance: 'fit'
});
var x = null;
$("#droppable").droppable({
drop: function(e, ui) {
x = ui.helper.clone();
x.draggable({
helper: 'original',
containment: '#droppable',
tolerance: 'fit'
});
/* text edit start */
$.fn.textedit = function(){
var defaultText = 'Text Edit';
function endEdit(e) {
var input = $(e.target),
label = input && input.prev();
label.text(input.val() === '' ? defaultText : input.val());
input.hide();
label.show();
}
$('.clickedit')
.focusout(endEdit)
.keyup(function (e) {
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
endEdit(e);
return false;
} else {
return true;
}
})
.prev().click(function () {
$(this).hide();
$(this).next().show().focus();
});
}
x.textedit();
/* text edit End */
x.find('.ui-resizable-handle').remove();
x.resizable();
x.appendTo('#droppable');
ui.helper.remove();
}
});
});
解决方案
mmmhhh 我想也许你想看看 html 属性:contentEditable。
您可能还会在那里找到一些不错的插件来执行此操作。
推荐阅读
- docker - 完成 docker run 后无法运行 localhost
- angular - Angular 6-*ngFor 与自定义排序和分页 - 如何应用
- ios - 如何通过单击添加按钮和在同一视图控制器中创建的删除按钮来添加和删除视图控制器中的段?
- java - 增强的 for 循环似乎同时遍历所有元素。但它应该是还是我的代码错了?
- c# - 如何将原始 json 值存储在 Cookie 对象中?
- python - pandas groupby 并按不同因素聚合
- jquery - 动态添加+删除div中的可排序div
- google-maps - 想创建谷歌地图图层
- python - os.system 路径中有空格
- json - 如何将 Json 响应输入到 Empty ant 设计表中?