Feed fields in view by controller

1

I have used a way to load fields in the view as follows: I make a method returning a JSon in the controller, there I create a JQuery function that takes that return and nurtures the fields of the view, in the success of ajax. Well, that was an approach, which I learned when I worked with e-commerce. The question then is as follows. Is this approach among the best practices? Today I have a form with 4 tabs. How would you do then using this approach? Is there another better and more elegant way?

    
asked by anonymous 13.06.2014 / 15:14

1 answer

2

From what I understand, via Javascript you feed the HTML fields. You can make a separate HTML for each return, and only replace the entire HTML. This avoids having to leave a lot of logic in Javascript.

In the controller, you direct to the HTML with the data ready to display, and in javascript it only replaces an entire "div", for example.

    
13.06.2014 / 15:27