WallyJ
4 months ago

JQuery not working in Blade template

Posted 4 months ago by WallyJ

I am trying to use Typeahead to create an autocomplete search box in a view.

If I copy the full code from the tutorial into a blade file WITHOUT any @extends or @section areas, it works fine.

If I try to add the links and scripts to app.blade.php,

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.1/bootstrap3-typeahead.min.js"></script>

It seems to load in the browser fine, per the Chrome Inspection tool, but the functionality doesn't work.

The links in the head are there. The scripts at the bottom are there. I don't know why it isn't firing properly. When the code is on one page it works fine. When it comes from separate sections through Blade, it doesn't work. Anyone else seen this issue?

Please sign in or create an account to participate in this conversation.