Support the ongoing development of Laravel.io →
posted 10 years ago
Views Blade
Last updated 2 years ago.
0

You have two options (maybe more):

  1. Use AJAX to fetch data only (preferably in JSON format), and build the markup in javascript/jquery. Since the HTML is complicated, you can use templating engines like Mustache or similar. How this works is, that you have a HTML file with common HTML stuff and something like {{symbol}} and {{number}} where you need to. Then you just pass these values to this template file using Mustache.

  2. Fetch the entire HTML content (View with list of cards) by AJAX (not just JSON data) and paste it as the HTML to some element. You end up with code like this

jQuery

$.get('/cards', {}, function(data){
    $('#container').html(data)
});

Controller

function getCards()
{
   $cards = Card::all();

   $data = [
      'cards' => $cards
   ];

   return View::make('cards', $data)->render();
}

and the View

@foreach ($cards as $card)
<div class="card">
{{ $card->symbol }} //or whatever
</div>
@endforeach
Last updated 2 years ago.
0

Works nicely, Thanks!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

2akurate 2akurate Joined 13 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.