Feed view fields to controller

Asked

Viewed 58 times

1

I have used a way to load fields in the view as follows: I make a method by returning a Json in the controller, then create a Jquery function that takes this return and feeds the view fields, in the success of the ajax. Well, that was an approach,m that 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 then use this approach? There’s another way better and more elegant?

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 too much logic in Javascript.

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

  • In this case I don’t need dynamic html like I’ve been doing. Soon I would replace only the Textbox that would receive values, right? I don’t need to be creating dynamic html, right?

  • Yes. You can make HTML static.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.