安装了Wordpress 3.1之后,我使用的jquery插件选择箱不再100 %工作了
我在wordpress后端使用这个插件来用我可以应用css的自定义html代码替换我的<select></select>,但是使用wordpress 3.1,很多<select>没有被100%替换,例如,在替换代码中缺少了<option>
<select>
<option (some attributes...)>text</option>
<option (some attributes...)>text</option>
</select>应该被替换为(实际上不是替换,原来的<select>将被隐藏)
<div class="jquery-selectbox">
<div class="jquery-selectbox-moreButton"></div>
<div class="jquery-selectbox-list jquery-custom-selectboxes-replaced-list">
<span>text</span> /* option 1 */
<span>text</span> /* option 2 */
</div>
<span class="jquery-selectbox-currentItem">text of selected option</span>
</div>而实际结果是
<div class="jquery-selectbox">
<div class="jquery-selectbox-moreButton"></div>
<div class="jquery-selectbox-list jquery-custom-selectboxes-replaced-list">
/* nothing here */
</div>
<span class="jquery-selectbox-currentItem">nothing here</span>
</div>奇怪的是,仍然有相当多的<select>得到100%的替换。
我尝试过回滚到wordpress 3.0并重新安装wordpress 3.1两次,脚本在回滚到3.0时工作得很好,只要3.1被插入,问题就会发生。
我的测试站点中没有wp插件,jquery库首先完全加载,我的其他脚本都运行良好。但是我发现这个问题发生在哪里,我不知道为什么会这样。
return this.each(function() { // for each <select>
var _this = jQuery(this);
... // I added an alert here, alert(_this.attr('id')), to print <select> id, and all <select> id are catched
jQuery('option', _this).each(function(k,v){
... // I added a same alert at first line this function, only replaced 100% <select> id are catched
});
...
});这是插件代码所做的替换,对于所有没有得到100%替换的<select>,我上面评论的行没有得到实现,看起来就像被跳了一样。
有什么想法吗?
更新我删除了所有其他脚本和插件,这里是我的脚本中剩下的唯一代码
jQuery(document).ready(function() {
jQuery('#myadmin select').each(function() {
jQuery(this).find('option').addClass('huh?');
});
});所有的选项都没有被替换,100%的<select>没有得到类的‘嗯?’
更新2 I将更新1中的脚本更改为
jQuery(document).ready(function() {
jQuery('select option').addClass('huh?');
});你猜怎么着?所有的<option>都上过这门课。这看起来有点像jQuery,但是为什么WP3.1呢?
WP3.1将jQuery版本升级到1.4.4,我取消了注册,并将jQuery 1.4.2带回我的页面,现在一切都好了,所有<select>都被100%替换了
最后一个问题是如何将这个问题标为已解决的问题?
发布于 2011-02-28 05:41:20
https://wordpress.stackexchange.com/questions/10591
复制相似问题