How to configure data in the Ajax version of the Smart Admin theme?

I am creating a client application where I am developing a web service using Laravel5 at the end and I will use it using the Smart Admin theme , in particular the Ajax version.

I already worked with the HTML version of this theme, and I still used Laravel as the back end. I could just use the Blade templating engine provided by Laravel and paste the data into the views.

But now, since I will use the Ajax version, how should I template the data in the views. I can request a web service for the data and it will return it in JSON format. This part is clear to me, as I did before.

Most widgets have built-in integration, such as jquery data tables and the full calendar library used in the theme. I see that the data will be entered here, but what about the forum and other things. Should I manipulate the DOM using jQuery or is there a better way.

Angular provides a way that you can pass data from two sides, and I can use ng-repeat to enter it into tables and unordered lists, but how to do it here. Is there a template system that I can use for this?

+7
javascript jquery ajax laravel-5 smartadmin
source share
3 answers

Thanks for your answers, but unfortunately I can’t understand. Nevertheless, I appreciate your input.

Finally, I resort to using the rivet.js library. This library provides an easy and powerful solution for data binding + templating to create modern web applications.

They have good documentation to help with development.

Now I can simply convert the data to representations like { data.someAttribute } , as in the following code fragment:

 <section id="auction"> <h3>{ auction.product.name }</h3> <p>Current bid: { auction.currentBid | money }</p> <aside rv-if="auction.timeLeft | lt 120"> Hurry up! There is { auction.timeLeft | time } left. </aside> </section> 

And then I can just bind the auction tag of section # with the auction JSON object like this:

 rivets.bind($('#auction'), {auction: auction}) 

This made it easy to get my data from the server and create data templates in the views. Now the same web service can finally be used by mobile applications.

Hope this helps someone. :)

+2
source share

I understand that so far you have used Laravel to render HTML for you. Now you want to host the HTML / JS site on another machine and get all dynamic values ​​from Laravel via the API.

If so, you really need to implement all the dynamic functions yourself, and this is a significant job.

You can also use the same laravel application and let it serve your static HTML / JS on a part of the site, where you will invoke values ​​from the backend via the API and keep the other part of the site “normal” when you let Laravel render HTML that isn’t needs an API to get its dynamic values.

0
source share

This response began as a comment and was included in the response.

If you use angular, the best way is to save the templates in the angular application and get the data from the api. In your case, Laravel will be your API.

You use an authentication method such as JWT (JSON Web Token) to authenticate and receive data from the server through the API. This is very easy to do on Laravel.

All data will be received as json and can be easily displayed on templates in the client browser using angular. You do not need jQuery, you can use the angular directive to bootstrap (angular -strap).

I have not tested this topic. But if it was NOT written using angular directives, it will be difficult for you to display data using client-side templates.

0
source share

All Articles