如何使用wp_enqueue_script在wordpress中加载jquery对话框? [英] how to load jquery dialog in wordpress using wp_enqueue_script?

查看:154
本文介绍了如何使用wp_enqueue_script在wordpress中加载jquery对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

页面加载后如何加载jquery对话框?我的意思是我不想每次刷新页面时都加载它.

how can i load a jquery dialog once the page is loaded? I mean I don't want to load it everytime i refresh the page.

我知道这与Cookie有关.

I know it's something to do with cookies.

这是我的对话框

var $j = jQuery.noConflict();

$j(function(){

    $j(document).ready(function(){

      $j('#west').dialog({show: 'slow', modal: true, height: 600, width: 850, title: 'Price Comparison Popup', resizable: false, draggable: false});        
      });        

    });

推荐答案

我不确定我是否完全理解您的问题,但是如果您只是想向代码中添加jquery-ui脚本,请使用类似以下内容的

I'm not sure I fully understand your questions, but if you just want to add a jquery-ui script to your code, use something like:

//assuming you are working on a plugin
$plugin_url = plugins_url('myPlugin');
//register and enqueue the script
wp_register_script("jquery-dialog", $plugin_url . '/js/jquery.dialog.js', 'jquery');
wp_enqueue_style('jquery-dialog');

这将包括脚本,并确保在Wordpress的jQuery版本之后加载该脚本.

That will include the script, and make sure it is loaded after Wordpress's version of jQuery.

这篇关于如何使用wp_enqueue_script在wordpress中加载jquery对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆