0

I have a problem when I include jquery's plugin, image isn't visible. The image is included in a css file.

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

That plugin

example of my attempts. The code placed at

/webroot/protected/components/MyWidjet.php

in a method

init()

$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'
            });
        });");

Access rights are 777

2 Answers 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 :)

Sign up to request clarification or add additional context in comments.

Comments

0

http://codingtip.blogspot.com/2013/09/yii-register-client-script-add-javascript-css-file.html

http://www.yiiframework.com/forum/index.php/topic/5309-clientscript-register/

http://code.dimilow.com/yii-adding-javascript-into-your-views/

http://www.waytoblogger.com/2012/08/13/register-js-css-files-in-yii-framework/

Best way of global registering ClientScript?

:D

UPDATE: for every document you have to give relative path from index.php, since all requests are handled there

3 Comments

it isn't the answer on my question. That description how include a script and a css but I have another problem. When I include the css file the jquery's plagin is included but image in the file don't include.
Is it true to put the editor in a layout or a controller folder how there is said?
jquery's plagin I'm doing the editor for adding news

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.