dimanche 25 octobre 2015

Laravel 5: Javascript problems after uploading to server

After pushing my app to a live server, I noticed that none of the jquery code is working. It works fine locally, but not on a live host.

I changed all relative urls to full urls and still they wouldn't work.

Not really sure what to do here.

For example, on post/create I have tinymce.min.js and typeahead.js both not working. Typeahead.js simply won't fetch any records without showing any errors.

But if you goto: http://ift.tt/1H3rMPj

the json response is positive.

Uncaught SyntaxError: Unexpected token /

create:177 Uncaught ReferenceError: tinymce is not defined

Both tinymce.js and typeahead.js have correct paths in the generated html in "view source"

This is the JS on post/create.blade.php

@section('scripts')
    <link rel="stylesheet" href="{{ URL::asset('assets/css/typeahead.css') }}">
    <script src="{{ URL::asset('assets/js/typeahead.bundle.js') }}"></script>
    <script type="text/javascript" src="{{ asset('assets/js/tinymce/tinymce.min.js') }}"></script>

    <script type="text/javascript">
        $(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",
            });

            var subreddits = new Bloodhound({
                datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
                queryTokenizer: Bloodhound.tokenizers.whitespace,
                prefetch: 'http://ift.tt/1H3rMPj',
                remote: {
                    url: 'http://ift.tt/1LVFvgM',
                    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);
            });
        });
    </script>
@endsection

And these are the routes

Route::get('data/subreddits/{query?}', 'PostsController@getSubreddits');

What can I possibly do here?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1XscNYQ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire