E
E
edik892016-11-21 12:11:34
Yii
edik89, 2016-11-21 12:11:34

How to properly edit a script in yii2?

Faced a problem. There is a BackendAsset, the app.js script is connected in it. The code:

class BackendAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';

    public $css = [
        'css/style.css'
    ];
    public $js = [
        'js/app.js'
    ];

    public $depends = [
        'yii\web\YiiAsset',
        'common\assets\AdminLte',
        'common\assets\Html5shiv'
    ];
}

I edit js/app.js, add my code there, nothing works. Error in
Uncaught SyntaxError: Invalid or unexpected token
console
$(function() {
    "use strict";

    //Make the dashboard widgets sortable Using jquery UI
    $(".connectedSortable").sortable({
        placeholder: "sort-highlight",
        connectWith: ".connectedSortable",
        handle: ".box-header, .nav-tabs",
        forcePlaceholderSize: true,
        zIndex: 999999
    }).disableSelection();
    $(".connectedSortable .box-header, .connectedSortable .nav-tabs-custom").css("cursor", "move");
})����������������������������������������������������������������������������������������������������������������

What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2016-11-21
@webinar

assets have nothing to do with it. The problem is that you saved the file with the wrong encoding when editing. Just open the file again, add your code and save in the desired encoding.
As an option - it's the wonders of your editor. Try to open in another and save again.
Attention!!! Be sure to clear the assets folder. And check which encoding for yii and for the server are set.

E
edik89, 2016-11-21
@edik89

Decided by setting in nginx.conf
sendfile off;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question