2017-05-09 34 views
-1

我在wordpress中使用jquery ui dialog製作對話框。我遇到的問題是當對話框出現時,關閉按鈕'X'未顯示。示例如下。在jQuery UI中顯示'關閉'按鈕 - 帶有WP的對話框

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精簡版,它是在function.php

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

默認值是true,這將是發生在頁腳。我將該值更改爲false,以便將它放在標題中,就像我的jquery-ui腳本一樣。

+0

你好Amran,'jQuery'使用圖標圖片,應該會丟失。 – BlueSuiter

回答

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> 

之後,它工作正常。

+0

感謝您的幫助。我是否需要首先「註銷」我的引導腳本?如何用wordpress實現它?對不起,我仍然在學習wordpress :) – Amran

+0

只需更改順序並重新加載頁面。 –

+0

在我的'functions.php'上,我無法找到'jquery-ui.js'的腳本來替換它。我是否需要將其添加到我的'header.php'中,或者我可以在'functions.php'上添加腳本 – Amran

相關問題