使用 jQuery 创建就地编辑 div 并在其下方创建可用于编辑的新 div
我是 jQuery 的新手,想知道是否可以创建和编辑 -我可以点击就地 div,输入一些文本,保存它,然后立即在其下方动态弹出另一个 div,这将允许相同的功能进行输入和保存,等等。如果有人有任何想法,我们将不胜感激。
$(document).ready(function() {
$('.edit_area').editable(function(value, settings) {
return (value);
}, {
type: 'textarea',
onblur: 'submit',
indicator: 'Saving...',
callback: function(value, settings) {
var thisData = $(value);
$.post('<%=Url.Action("SetPostieNotes", "Posties") %>',
'postieNotes=' + escape(thisData)
);
var divTag = document.createElement("div");
divTag.id = "div";
divTag.setAttribute("align", "center");
divTag.className = "edit_area";
divTag.innerHTML = "Test Dynamic Div.";
document.body.appendChild(divTag);
}
});
});
I'm new to jQuery and would like to know if it is possible to create and edit-in-place div that I can click on, type some text, have it save and immediately have another div dynamically pop up beneath it that will allow the same capability to type in and save, so on and so forth. If anyone has any ideas it would be greatly appreciated.
$(document).ready(function() {
$('.edit_area').editable(function(value, settings) {
return (value);
}, {
type: 'textarea',
onblur: 'submit',
indicator: 'Saving...',
callback: function(value, settings) {
var thisData = $(value);
$.post('<%=Url.Action("SetPostieNotes", "Posties") %>',
'postieNotes=' + escape(thisData)
);
var divTag = document.createElement("div");
divTag.id = "div";
divTag.setAttribute("align", "center");
divTag.className = "edit_area";
divTag.innerHTML = "Test Dynamic Div.";
document.body.appendChild(divTag);
}
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 jEditable 进行就地编辑功能,并使用它的回调函数来生成新的div 低于现有的。
您并没有真正使用 jEditable 提供的所有功能,请尝试这样的操作(我现在无法测试它,但它应该会给您一些想法):
这应该就是全部了。您不需要自己提交,这就是 jEditable 的用途。只需提供您想要保存的 URL 作为第一个参数,并将设置作为第二个参数。
Use jEditable for the edit-in-place functionality, and use it's callback functions to spawn the new div below the existing one.
You're not really using all that jEditable has to offer, try something like this (I am unable to test this right now but it should give you some ideas):
That should be all there is to it. You don't need to do the submitting yourself, that's what jEditable is for. Just supply the URL you wish to save to as the first parameter, and settings as the second.
我实际上是从使用 jEditable 开始的,然后转向 tectual 的 editables() 插件
这是我正在使用的代码 https://github.com /relipse/jQuery-Editable/blob/master/jquery.editable.js
I actually started by using jEditable and moved on to tectual's editables() plugin instead
Here is the code i'm using https://github.com/relipse/jQuery-Editable/blob/master/jquery.editable.js