jquery集选择选项对html没有影响
我有这个htmljquery集选择选项对html没有影响,jquery,firefox,firefox3.6,html-select,Jquery,Firefox,Firefox3.6,Html Select,我有这个html <select name="grid.SprintModel" id="grid_SprintModel"> <option value=""><None></option> <option value="739af096-a732-49ea-b9fc-d9220a25ed36">1. Meilenstein: Spezifikation</option> <option
<select name="grid.SprintModel" id="grid_SprintModel">
<option value=""><None></option>
<option value="739af096-a732-49ea-b9fc-d9220a25ed36">1. Meilenstein: Spezifikation</option>
<option value="94749a48-fe3b-4f03-8757-4b07257f6c18">2. Meilenstein: Test</option>
<option value="775efd45-b90f-43f9-84e6-6eb7cf1f05d7">3. Meilenstein: Qualitätsrelease</option>
</select>
没有一个
1.梅伦斯坦:斯佩齐菲卡蒂翁
2.梅伦斯坦:测试
3.梅伦斯坦:质量释放
然后我有了这个jquery
function onConfigureSprintSelection() {
// find the dropdown first
var $dropdown = $('select[name$=grid.SprintModel]');
$('<option/>', { text: '<None>', value: '' })
.prependTo($dropdown);
// find the table row (tr) which is being edited
var $tr = $dropdown.closest('tr:has(form)');
// get the grid client object
var grid = $tr.closest('.t-grid').data('tGrid');
// get the data item bound to this table row
var dataItem = grid.dataItem($tr);
// set the value of the dropdown to select the proper item
var value = dataItem.SprintModel ? dataItem.SprintModel.RowKey : '';
$dropdown.val(value);
var xyz = 1; // Just a row for a breakpoint
}
函数onConfigurePrintSelection(){
//首先找到下拉列表
var$dropdown=$('select[name$=grid.SprintModel]');
$('',{text:'',值:'})
.prependTo($dropdown);
//查找正在编辑的表行(tr)
var$tr=$dropdown.closest('tr:has(form)');
//获取网格客户端对象
var grid=$tr.closest('.t-grid').data('tGrid');
//获取绑定到此表行的数据项
var dataItem=grid.dataItem($tr);
//设置下拉列表的值以选择适当的项目
var值=dataItem.SprintModel?dataItem.SprintModel.RowKey:“”;
$dropdown.val(值);
var xyz=1;//仅一行作为断点
}
如果调试jquery,则dom树将正确更改:
- 将插入“无”选项
- 当前选项被选中=真
出现。
当前选定的选项不显示。
它总是出现:
- 这个问题只发生在firefox中
- 在ie中,它工作得很好
- 在狩猎中还有另一个问题。未选择正确的选项。字段是空的
我记得在早期的firefox版本中,它曾经正常工作。我有3.6.13。您的第一个问题是需要在此选择器中引用属性值:
$('select[name$="grid.SprintModel"]')
接下来,$('',{text:'',value:''})
将创建:
<option text="<None>" value="" />
而不是:
<option value=""><None></option>
无
这就是我想你会想要的
最后,我找不到任何名为dataItem()
的jQuery方法
很抱歉,这并不是一个确切的答案,但非标准代码通常会导致复杂问题。因此,请仔细查看您正在使用的jQuery,并尝试简化它。dataItem()不是问题所在。它返回周围标记的json数据项。这个很好用。正如我所说的:DOM树被正确地更改了,但是在firefox和safari中它没有正确地呈现,但是在ie中它是正确的。