I using laravel 4 and typeahead.js, but get error message becouse the {{}} delimiters are the same of the JQuery.
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#pessoa_id').typeahead([
{
name: 'planets',
remote: '/sistema/lancamento/pessoa/%QUERY',
template: '<p><strong> {{pessoa_id}} </strong> – {{nome}} </p>',
]);
Any sugestion ?
Thanks. Helder
You can change the delimiters as montogeek suggests, but it's probably easiest to just prepend it with an @
symbol.
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#pessoa_id').typeahead([
{
name: 'planets',
remote: '/sistema/lancamento/pessoa/%QUERY',
template: '<p><strong> @{{pessoa_id}} </strong> – @{{nome}} </p>',
]);
Laravel will not try to parse it.
http://laravel.com/docs/templates#other-blade-control-structures
You can change the delimiters of Blade in the controller or in a route
Route::get('/', function()
{
Blade::setEscapedContentTags('[[', ']]');
Blade::setContentTags('[[[', ']]]');
return View::make('home');
});
That will change the delimiters that use Blade for that view.
Hope that helps!
You can use Json syntax within a blade file, only {{ }} and {{{ }}} are used to evaluate PHP..
But you do have some badly formatted Json which is probably causing your bracket miss match problem.
[{
name: "planets",
remote: "/sistema/lancamento/pessoa/%QUERY",
template: "<p><strong> {{pessoa_id}} </strong> – {{nome}} </p>"
}]
EDIT:
After looking at typeahead.js I see that you will need to change delimiters as per @montogeek answer too.