lundi 26 octobre 2015

Hosting laravel 5 app on shared hosting: getting js error "tinymce is not defined"

I know hosting laravel 5 app on shared hosting can be tricky but it's not impossible.

So I followed this tutorial's instructions http://ift.tt/1eXRltP

I moved the app files into a directory called /reddit/ outisde /public_html/ and the files inside the app's /public/ folder into the hosting's /public_html/

Then I made changed to index.php in the /public_html/ to point to the correct path

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

The app loads fine, but when I try to submit a new subreddit/category which requires the tinymce editor, it doesn't load and I get this error in the console

Uncaught SyntaxError: Unexpected token / create:203 Uncaught

ReferenceError: tinymce is not defined

I am positive the html markup is pointing to the correct tinymce.min.js because if I view source, and click on the js link, the script loads in the browser.

My app is here: http://maghnatis.com

If you wanna see what's going on.

This is how I'm initializing it

$(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>

I'm afraid this isn't a problem with tinymce but rather how my app is loading the js files on the shared hosting. I believe I will get into my js errors with other libraries if I don't fix this.

I might add that typeahead.js is not working either. Doesn't retrieve records from the database even though the json response is positive.

http://ift.tt/1RxEMCC

This is the JS code to 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>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire