jScrollPane jEditable DOM 问题
我遇到了一个奇怪的问题。
这是我的代码。我运行 getJSON() 从 PHP 中获取信息,该信息从数据库中提取,然后用结果填充 div。我有 jScrollPane 和 jEditable,因此用户可以向下滚动并单击以编辑任何内容。它有时起作用,然后不起作用,这让我想知道浏览器是否没有正确解释代码,或者我是否误解了这里的基本 DOM 概念......
$().ready(function() {
$('#pane1').jScrollPane();
$('#tab_journal').tabs();
$('#tab2').load("/journal_new.php");
var i=0;
var row = '';
var k, v, dt;
$.getJSON("/ajax.php?j=22", function(data) {
row = '<p>';
while(i<data.length) {
$.each(data[i], function(k, v) {
if (k == 'subject') {
row += '<div style="font-size:1.5em; color:#000000;"><div class="editable" style="width:705px;" id="title-'+data[i].id+'">'+v+'</div></div>posted: '+dt+'<br />';
} else if (k == 'dt') {
dt = v;
} else if (k == 'msg') {
row += '<div class="editableMsg" style="width:705px; height:40px;" id="msg-'+data[i].id+'">'+v+'</div></p>';
}
});
i++;
}
$('#pane1').append(row).jScrollPane({scrollbarWidth:10, scrollbarMargin:10, showArrows:true});
});
$('.editable').livequery(function () {
$('.editable').editable("/savejournal.php", {
submitdata : function() {
},
tooltip : 'Click to edit',
indicator : '<img src="/UI/images/indicator.gif">',
cancel : 'Cancel',
submit : 'OK'
});
$('.editableMsg').editable("/savejournal.php", {
submitdata : function() {
},
tooltip: 'Click to edit',
indicator : '<img src="/UI/images/indicator.gif">',
cancel : 'Cancel',
submit : 'OK',
type : 'textarea'
});
$(".editable,.editableMsg").mouseover(function() { $(this).css('background-color', '#FDD017'); });
$(".editable,.editableMsg").mouseout(function() { $(this).css('background-color', '#fff'); });
});
});
然后是 HTML:
<div id="tab_container" style="margin:0px 0px 2px 8px;">
<ul id="tab_journal">
<li><a href="#tab1"><span>View / Edit</span></a></li>
<li><a href="#tab2"><span>New Entry</span></a></li>
</ul>
</div>
<div id="tab1" style="margin:0px 0px 0px 8px;">
<div id="pane1" class="scroll-pane super-wide"></div>
</div>
<div id="tab2" style="margin:0px 0px 0px 8px; width:700px;"></div>
谢谢世界。
I am having a funky problem.
Here's my code. I run getJSON() to fetch the info from the PHP which pulls from DB and I fill a div with the result. I have jScrollPane and jEditable so a user can scroll down and click to edit any of the content. It works sometimes and then it doesn't work which makes me wonder if the browser is not interpreting the code properly or if I am misunderstanding fundamental DOM concepts here....
$().ready(function() {
$('#pane1').jScrollPane();
$('#tab_journal').tabs();
$('#tab2').load("/journal_new.php");
var i=0;
var row = '';
var k, v, dt;
$.getJSON("/ajax.php?j=22", function(data) {
row = '<p>';
while(i<data.length) {
$.each(data[i], function(k, v) {
if (k == 'subject') {
row += '<div style="font-size:1.5em; color:#000000;"><div class="editable" style="width:705px;" id="title-'+data[i].id+'">'+v+'</div></div>posted: '+dt+'<br />';
} else if (k == 'dt') {
dt = v;
} else if (k == 'msg') {
row += '<div class="editableMsg" style="width:705px; height:40px;" id="msg-'+data[i].id+'">'+v+'</div></p>';
}
});
i++;
}
$('#pane1').append(row).jScrollPane({scrollbarWidth:10, scrollbarMargin:10, showArrows:true});
});
$('.editable').livequery(function () {
$('.editable').editable("/savejournal.php", {
submitdata : function() {
},
tooltip : 'Click to edit',
indicator : '<img src="/UI/images/indicator.gif">',
cancel : 'Cancel',
submit : 'OK'
});
$('.editableMsg').editable("/savejournal.php", {
submitdata : function() {
},
tooltip: 'Click to edit',
indicator : '<img src="/UI/images/indicator.gif">',
cancel : 'Cancel',
submit : 'OK',
type : 'textarea'
});
$(".editable,.editableMsg").mouseover(function() { $(this).css('background-color', '#FDD017'); });
$(".editable,.editableMsg").mouseout(function() { $(this).css('background-color', '#fff'); });
});
});
And then the HTML:
<div id="tab_container" style="margin:0px 0px 2px 8px;">
<ul id="tab_journal">
<li><a href="#tab1"><span>View / Edit</span></a></li>
<li><a href="#tab2"><span>New Entry</span></a></li>
</ul>
</div>
<div id="tab1" style="margin:0px 0px 0px 8px;">
<div id="pane1" class="scroll-pane super-wide"></div>
</div>
<div id="tab2" style="margin:0px 0px 0px 8px; width:700px;"></div>
Thanks world.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已经无法破解了。似乎代码行:
并没有让浏览器满意。
Have been unable to break. Seems that the line of code:
was not making the browser happy.