【问题标题】:how to load jquery dialog in wordpress using wp_enqueue_script?如何使用 wp_enqueue_script 在 wordpress 中加载 jquery 对话框?
【发布时间】:2012-02-25 01:48:20
【问题描述】:

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

我知道这与 cookie 有关。

这是我的对话

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

    });

【问题讨论】:

  • 我看不出这与 wp_enqueue_script 有什么关系。此外,您正在将文档就绪函数包装在文档就绪函数中。你只需要一个。 ;-)
  • @Ronny:“我知道这与 cookie 有关。”不,你不知道。

标签: php jquery wordpress


【解决方案1】:

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

//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 版本之后加载的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-08
    相关资源
    最近更新 更多