我修改了创建新笔记的代码示例
这个也附加了提交事件回调函数中新添加的表单
关闭加载事件。
这是一个进步
因为出于某种原因,其他示例没有完成这项工作。
我不知道这样做有什么缺点,但是!
我愿意接受任何关于这个问题的 cmets
如果你想要see example
目的&评论:
newnote 函数有两个参数
-: index = 页面上已经存在的音符数
-: tbnoteid = 数据库中的noteid
索引也应该像显示消息的计数器一样。
例如,如果计数器超过 10,则应该从页面和数据库中删除标准上的消息,因为最后一个是第一个输出(具有最旧时间戳的消息)(逻辑也已稍后添加)
允许表单执行的唯一操作是从数据库中删除消息并从页面中删除自身(容器 div)。出于静态目的,它首先淡出。
该函数可以接受更多参数,例如消息本身。
当用户进入页面时,应该从另一个函数调用 newnote 函数,该函数从数据库中提取消息(如果有的话)。
该链接也会生成一个新注释,该链接将被其他形式的操作所取代,例如this example
$(document).ready(function(){
$('a[name=modal]').click(function(e) { //the selector is for testing purpose
//Cancel the link behavior
e.preventDefault();
var $aantal = $("div.pane").size()
newnote($number+1,1); // second argument is supposed too come from the database
});
function newnote(index,tbnoteid) {
$("div.wrapper:last").after('<div class="wrapper"></div>');
$('.wrapper:last').load('tbnote.html .pane', function() {
$(".pane:last").prepend("testmessage"); //testpurpose
$('.pane:last #frmnoteid').val(tbnoteid);
$(this,".frm" ).attr('id' , index);
var $id = $(this).attr('id'); "); //testpurpose
$('.frm:last').submit(function(){
$.post("tbnotes.php",{
noteid: $("#frmnoteid").val(),
actie: "verwijder",
tijd: timestamp}, function(xml) {
addMessages(xml);
});
alert("Hello mijn id = " + $id );"); //testpurpose
$(this).parents(".pane").animate({ opacity: 'hide' }, "slow");
$(this).parents(".wrapper").remove();
return false;
});
});
}