这个 jQuery 语句是做什么的?
function setReplicate()
{
$('.replicate').live("click",function(){
var nm=$(this).attr('name');
var cntr=$(this).attr('cntr');
var vpmo=$(this).attr('vpmo');
var vl=$(this).parent().prev().find("select").val();
$('[name="'+nm+'"][vpmo="'+ vpmo + '"]').each(function() {
if ($(this).attr("cntr") >= cntr)
$(this).parent().prev().find("select").val(vl);
});
});
}
有一个项目编号以及分配给该项目的系统。每个系统都有关于它的详细信息,并通过循环表来输出。表内有一个选择列表 - 有些将预先填充值,但其他则不会。其中有选择列表和一个带有 jQuery 选择器的图标,这样当单击该图标时,选择列表中的值将应用于项目中的其他系统。只要选择列表中的值没有预先填充的值(在页面加载期间从数据库读取 - 发生 noajax 或其他操作),此函数就可以完美运行。不会生成任何错误,如果我输入警报,我会得到我期望的值,直到
if ($(this).attr("cntr") >= cntr)
$(this).parent().prev().find("select").val(vl);
});
我怀疑问题就在这里。
以下代码是为 Coldfusion 自定义标签生成的,这就是 FF 在查看生成的源代码时看到的内容:
<select name="resource" id="resource_12345_200002" class="resource_12345" selection="">
<option>Donald Duck</option
<option>Mickey Mouse</option>
...
<option>Goofy</option>
</selected>
<select name="resource" id="resource_12345_200003" class="resource_12345" selection="Donald Duck">
<option select="selected">Donald Duck</option>
<option>Mickey Mouse</option>
...
<option>Goofy</option>
</select>
值“Donald Duck”应该能够应用于列表中此时及下方的剩余选择项(因此, cntr >= cntr 值的原因是,
我办公室里有人会在早上和我一起检查这个问题,所以不要花太多时间看这个,我只是希望得到一个答案。 。
开始
function setReplicate()
{
$('.replicate').live("click",function(){
var nm=$(this).attr('name');
var cntr=$(this).attr('cntr');
var vpmo=$(this).attr('vpmo');
var vl=$(this).parent().prev().find("select").val();
$('[name="'+nm+'"][vpmo="'+ vpmo + '"]').each(function() {
if ($(this).attr("cntr") >= cntr)
$(this).parent().prev().find("select").val(vl);
});
});
}
There is a project number with systems assigned to the project. Each system has details about it and are outputted by looping over tables. Within the table is a select list - some will have values prepopulated but others will not. Within the is the select list and an icon with a jQuery selector tied to it so that when the icon is clicked, the value in the select list is applied to the other systems wihtin the project. This function works perfectly as long as the values in the select list does not have a value prepopulated (read from the database during page load - noajax or other manipulations are occurring). No errors are generated and if I put in alerts, I get the values I expect until the
if ($(this).attr("cntr") >= cntr)
$(this).parent().prev().find("select").val(vl);
});
so I suspect the issue is within here.
The following code is generated for a coldfusion custom tag and this is what FF sees when I view generated source code:
<select name="resource" id="resource_12345_200002" class="resource_12345" selection="">
<option>Donald Duck</option
<option>Mickey Mouse</option>
...
<option>Goofy</option>
</selected>
<select name="resource" id="resource_12345_200003" class="resource_12345" selection="Donald Duck">
<option select="selected">Donald Duck</option>
<option>Mickey Mouse</option>
...
<option>Goofy</option>
</select>
The value, 'Donald Duck' should be able to be applied to the remaining select items from this point in the list and below (thus the reason for the cntr >= cntr values.
I've got someone in the office going to look this over with me in the morning so don't spend too much time looking at this. I just was hoping to get a head start.
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,某些 vpmo 编号中有一个尾随空格(vpmo 就是以这种方式导入的)。我们对报表进行了修剪,现在效果符合预期。谢谢你们的评论。
Turns out some of the vpmo numbers had a trailing space in it (the vpmo are being imported that way). We applied a trim to the statements and now this is performing as expected. Thanks for the review guys.