-1

I am making a dialog box using jquery ui dialog in wordpress. The problem that I am having is when the dialog box appear, the close button 'X' is not shown. example as below.

enter image description here

I have make some reading regarding this issue and it is due to conflict on bootstrap. Reference on Stackoverflow. How do I want to implement it on wordpress? Below are my codes on functions.php that I made

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');

Update Solutions:

Currently I am using Zerif Lite on my theme and it is on function.php.

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

The default value is true that will be place in footer. I change the value to false so that it will be place in the header as same as my jquery-ui scripts.

Community
  • 1
  • 1
Amran
  • 627
  • 3
  • 11
  • 30

1 Answers1

1

The reason this is happening, is because you are calling bootstrap in, after you are calling jquery-ui in.

swap the two so that instead of:

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

it becomes

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

after that it works fine.

Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59