在jQuery UI中显示“关闭”按钮 - 带WP的对话框

时间:2017-05-09 04:41:40

标签: php jquery wordpress twitter-bootstrap

我正在使用wordpress中的jquery ui dialog创建一个对话框。我遇到的问题是出现对话框时,未显示关闭按钮'X'。例如如下。

enter image description here

我已经就这个问题做了一些阅读,这是由于bootstrap上的冲突。 Reference on Stackoverflow.我如何在wordpress上实现它?以下是我在functions.php创建的代码

function add_my_script() {     
   if(is_page('my_custom_page')){
     //Tried to deregister bootsrap and it work fine but I need the boostrap as well. 
     //wp_deregister_script('zerif_bootstrap_script');
     //Tried to degregister and enqueue back the script to follow the rules base on reference  
     //wp_enqueue_script('zerif_bootstrap_script', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '20120206', true);
     wp_enqueue_script('jquery-ui-dialog');
   }

}

add_action('wp_enqueue_scripts', 'add_my_script');
  

更新解决方案:

目前我在我的主题上使用 Zerif Lite ,它位于function.php

wp_enqueue_script('zerif_bootstrap_script', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '20120206', false);

默认值为true,将放在页脚中。我将值更改为false,以便它将与我的jquery-ui脚本一样放在标题中。

1 个答案:

答案 0 :(得分:1)

发生这种情况的原因是,在您拨打bootstrap之后,您正在呼叫jquery-ui

交换这两个而不是:

<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="js/bootstrap.min.js"></script>

它变成了

<script src="js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

之后它运作正常。