让对象留在脚本化的可放置对象中
当我查看人们添加到 Scriptaculous 的内容时,我发现了一些有趣的代码,并且我正在尝试根据我的目的修改它。 我几乎完成了所有工作,除了当我粘贴放置处理程序代码时,我的页面停止加载。
以下是相关的片段:
对于可拖动:
for (i=0; i<=50; i++){
Squad = 'Squad' + i
if($(Squad)){
new Draggable(Squad,{revert:true});
对于可放置:
Droppables.add('ToEast', {
accept: ["Nurse","Squad","Doctor"],
onDrop:function(e){DropHandler(e,'ToEast')}
});
drophandler:
function DropHandler(element,el){
var newnode = document.createElement('img');
var classname = element.className;
newnode.src="images/"+IdCatcher+".jpg";
newnode.id = IdCatcher;
$(el).appendChild(newnode);
newnode.setAttribute("class", 'classname');
newnode.setAttribute("className", 'classname);
new Draggable(newnode.id,{revert:true});
element.parentNode.removeChild(element);
}
我用“alert()”替换了代码,它开始工作正常,所以最后一个块中的某些内容不能很好地工作。 我必须修改他们的很多代码才能使其与当前版本的 scriptaculous 兼容,但我不太熟悉,所以它可能与旧代码有关? 或者可能只是有什么问题,我不够好看到的。
I found some interesting code when I was looking at things that people had added on to Scriptaculous, and I'm trying to modify it for my purposes. I got nearly all of it working, except when I paste in the drop handler code, my page stops loading.
Here's the relevant snipits:
For draggables:
for (i=0; i<=50; i++){
Squad = 'Squad' + i
if($(Squad)){
new Draggable(Squad,{revert:true});
For Droppables:
Droppables.add('ToEast', {
accept: ["Nurse","Squad","Doctor"],
onDrop:function(e){DropHandler(e,'ToEast')}
});
The drophandler:
function DropHandler(element,el){
var newnode = document.createElement('img');
var classname = element.className;
newnode.src="images/"+IdCatcher+".jpg";
newnode.id = IdCatcher;
$(el).appendChild(newnode);
newnode.setAttribute("class", 'classname');
newnode.setAttribute("className", 'classname);
new Draggable(newnode.id,{revert:true});
element.parentNode.removeChild(element);
}
I replaced the code with "alert()" and it started working fine, so something in that last block isn't working well. I had to modify a lot of their code to make it work with the current version of scriptaculous, but i'm not all that familiar, so it could have something to do with old code? Or there could just be something wrong with it that I'm not good enough to see.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在该行末尾缺少结束引号:
如果仍然存在问题,我建议您尝试使用 Firebug< 调试脚本/a> 查看哪一行导致错误。
You are missing a closing quote on the end of this line:
If there's still a problem, I suggest you try debugging the script using Firebug to see which line causes an error.