我想创建拖放电子邮件模板生成器。我试过下面的代码但没有用。拖入右侧框后想编辑文本编辑器
点击这里my code
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。
您可能还会在那里找到一些不错的插件来执行此操作。
关于jquery - 使用 jquery 拖放电子邮件模板生成器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50387776/