【问题标题】:Show 'Close' Button in jQuery UI - Dialog Box with WP在 jQuery UI 中显示“关闭”按钮 - 带有 WP 的对话框
【发布时间】:2017-05-09 04:41:40
【问题描述】:

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

我已经阅读了有关此问题的一些信息,这是由于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 脚本一样放置在标题中。

【问题讨论】:

  • 您好 Amran,jQuery 使用图标图像,它应该丢失了。

标签: php jquery wordpress twitter-bootstrap


【解决方案1】:

发生这种情况的原因是因为您在调用 jquery-ui in 之后调用了 bootstrap in。

交换两者,而不是:

<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>

之后就可以正常使用了。

【讨论】:

  • 感谢您的帮助。我需要先deregister 我的引导脚本吗?如何用wordpress实现它?抱歉,我还在学习 wordpress :)
  • 只需更改顺序并重新加载页面即可。
  • 在我的functions.php 上,我找不到jquery-ui.js 的脚本来替换它。我需要将它添加到我的header.php 还是我可以将脚本添加到functions.php
  • 通过检查页面在页面中搜索它。如果它存在于 header 中,则打开 header.php,如果是最后打开 footer.php
  • 找到了!感谢@MayankPandeyz 提供详细信息
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-11
  • 2014-08-22
  • 1970-01-01
  • 2011-04-18
相关资源
最近更新 更多