繁体   English   中英

在共享主机上托管laravel 5应用程序:出现js错误“未定义tinymce”

[英]Hosting laravel 5 app on shared hosting: getting js error “tinymce is not defined”

我知道在共享主机上托管laravel 5应用程序可能会很棘手,但这并非不可能。

所以我遵循了本教程的说明https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e

我将应用程序文件移到名为/reddit/ outisde /public_html/的目录中,并将应用程序的/public/文件夹中的文件移至托管服务器的/public_html/

然后我将更改为/public_html/中的index.php以指向正确的路径

ini_set('eaccelerator.enable', 0);
require __DIR__.'/../reddit/bootstrap/autoload.php';
$app = require_once __DIR__.'/../reddit/bootstrap/app.php';

该应用程序可以正常加载,但是当我尝试提交需要tinymce编辑器的新subreddit / category时,该应用程序无法加载,并且在控制台中出现此错误

Uncaught SyntaxError:意外的令牌/创建:203 Uncaught

ReferenceError:未定义tinymce

我很肯定html标记指向正确的tinymce.min.js因为如果我查看源代码并单击js链接,则脚本会加载到浏览器中。

我的应用程序在这里: http : //maghnatis.com

如果您想看看发生了什么。

这就是我初始化的方式

$(document).ready(function() {
        tinymce.init({
            selector : "textarea",
            menubar    : false,
            plugins : ["advlist autolink lists link image charmap print preview anchor", "searchreplace visualblocks code fullscreen", "insertdatetime media table contextmenu paste"],
            toolbar : "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
        });
    });

<p>
    {!! Form::label('description', 'Description:') !!}
    {!! Form::textarea('description', null, ['class' => 'form-control']) !!}
</p>

恐怕这不是tinymce的问题,而是我的应用程序如何在共享主机上加载js文件。 我相信,如果我不解决这个问题,我会在其他库中遇到我的js错误。

我可能会补充说typeahead.js也不起作用。 即使json响应为肯定,也不会从数据库中检索记录。

http://maghnatis.com/data/subreddits

这是typeahead.js的JS代码

 $(document).ready(function() {
        var subreddits = new Bloodhound({
            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
            queryTokenizer: Bloodhound.tokenizers.whitespace,
            prefetch: 'data/subreddits',
            remote: {
                url: 'data/subreddits/%QUERY',
                wildcard: '%QUERY'
            }
        });

        $('#remote .typeahead').typeahead(null, {
            name: 'name',
            display: 'name',
            source: subreddits
        });

        $('#remote .typeahead').bind('typeahead:select', function(ev, suggestion) {
            $('.subreddit_id').val(suggestion.id);
        });
    });

<div id="remote">
    <input class="form-control typeahead" type="text" placeholder="Choose a Subreddit" name="subreddit_name">
    <input type="hidden" class="subreddit_id" value="" name="subreddit_id">
</div>

我已经将其发布在Laracasts上,但是我浏览了您的网站。 TinyMCE在我这方面工作正常,但是您的输入路径错误,这就是为什么您遇到了这个问题。 这就是你现在所拥有的。

var subreddits = new Bloodhound({
    datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
    queryTokenizer: Bloodhound.tokenizers.whitespace,
    prefetch: 'data/subreddits',
    remote: {
        url: 'data/subreddits/%QUERY',
        wildcard: '%QUERY'
    }
});

'data/subreddits',应为'/data/subreddits' ,以使其与根相对。 否则,它将相对于当前URL。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM