簡體   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