2015-10-26 17 views
0

我知道在共享主机上托管laravel 5应用程序可能会很棘手,但这不是不可能的。在共享主机上托管laravel 5应用程序:获取js错误“tinymce未定义”

所以我跟着这个教程的说明 https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e

我感动的应用程序文件到一个名为/reddit/ outisde /public_html/目录和文件的应用程序的/public/文件夹内到托管的/public_html/

然后我做了改变index.php/public_html/指向正确的路径

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

该应用程序加载罚款,但是当我尝试提交新的版(Subreddit)/类别要求TinyMCE的编辑器,它不会加载,我得到这个错误在控制台

Uncaught SyntaxError: Unexpected token/create:203 Uncaught

ReferenceError: tinymce is not defined

我肯定的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

这是JS代码typeahead.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> 
+0

什么文件和什么行号引起意外的令牌错误? – Steve

+0

它在'tinymce.min.js'行6 – Halnex

回答

1

我已经张贴了这个对Laracasts,但我看了一下您的网站。 TinyMCE在我的最后工作正常,但是你的路径对于typeahead是错误的,这就是为什么你会遇到这个问题。这就是你现在所拥有的。

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。

+0

tinymce如何在你的最后但不是我的?无论我多么努力地刷新,我仍然会得到同样的错误。将斜线添加到数据网址也没有帮助。 – Halnex

+0

我用TOR打开网站,似乎一切正常。然而,我正面临着一个新的错误,我把它发布在laracast上,你会介意看看它吗?基本上它从图像文件名中省略了“{$ extension}”',并且不保存到图像目录 – Halnex

相关问题