0

当我包含 jquery 的插件时出现问题,图像不可见。该图像包含在一个 css 文件中。

div{background-image:url('famfamfam.png');background-repeat:no-
repeat;width:16px;height:16px}

那个插件

我尝试的例子。代码放置在

/webroot/protected/components/MyWidjet.php

在一个方法中

在里面()

$cs = Yii::app()->clientScript;
        $cs->registerCssFile(Yii::app()->assetManager->publish(dirname(__FILE__).'/css/ 
 editor.css'));
     $cs->registerPackage(Yii::app()->assetManager->publish(dirname(__DIR__).'/vendor/
 minified/'));
        $cs->registerCssFile(Yii::app()->assetManager->publish(dirname(__DIR__) .
                '/vendor/minified/themes/default.min.css'));
        $cs->registerScriptFile(Yii::app()->assetManager->publish(dirname(__DIR__) .
                '/vendor/minified/jquery.sceditor.bbcode.min.js'));

  echo CHtml::script("$(function() {
            $('textarea').sceditor({
                plugins: 'bbcode',
                toolbar: 
  'bold,italic,horizontalrule,underline,strike,subscript,superscript|left,center,right,\
                justify|size,color|bulletlist,orderedlist|table|
  code,quote,image,link,unlink|maximize,source',
            locale: 'ru',
            charset: 'utf-8',
            autofocus: true,
            enablePasteFiltering: true,
            spellcheck: true,
            style: 'minified/jquery.sceditor.default.min.css'
            });
        });");

访问权限为 777

4

2 回答 2

1

One way of doing it theme-wide:

Add the clientScript calls to your themes/themename/views/layouts/main.php in the head, or wherever you want.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>    
<?php Yii::app()->clientScript->registerCoreScript('cookie'); ?>        
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
.....

Or you can add them to controller methods, or in various other places. But this will make sure Jquery is plagged in everywhere :)

于 2014-05-02T02:04:16.450 回答