我有 4 个使用 Jquery UI 的“按钮”功能的按钮。 3 工作完美无缺。第四个似乎不想在悬停时始终应用 jquery ui 悬停类“ui-state-hover”。它有时会这样做,但大多数时候它只应用“悬停”类(我在 firebug 中观看它),这显然与它们的 css 样式不匹配。有谁知道到底是什么原因导致了这种差异?
编辑:我认为这是 UI 按钮和 Ajax uploader 之间的冲突。这是我正在使用的一些精简代码。
$('.upload_img').button({
icons: {
primary: 'ui-icon-folder-open'
},
label: "Browse"
})
jQuery('.upload_img').each(function(){
var button = jQuery(this);
var ID = jQuery(this).attr('value');
var container = jQuery(this).parent();
//prevent the clicks from its default 'form submit' behavior
$(this).click(function() {
return false;
});
new AjaxUpload( button, {
action: ajaxurl,
name: ID , // File upload name
data: { // Additional data to send
action: 'save_function',
type: 'upload',
_nonce: '<?php echo $nonce; ?>',
key: ID },
onSubmit: function(file , ext){
this.disable(); // If you want to allow uploading only 1 file at time, you can disable upload button
},
onComplete: function(file, response) {
this.enable(); // re-enable upload button
if(response == 99){
//alert(response);
show_message(5); // failure
t = setTimeout('fade_message()', 2000);
}
// If there was not an error
else{
show_message(4); // success
t = setTimeout('fade_message()', 2000);
}
}
});
});
最佳答案
重新启用后,您是否尝试将 .button
重新附加到 .upload_img
上?
关于jquery ui按钮不一致的悬停状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3304767/