How to organize code for javascript UI widget?

The web application I'm working on has some fairly complex and robust client interface elements. I am trying to maintain common sense by organizing them into javascript composite widgets. Some of the requirements are:

1) Some of the data necessary to initialize the widget must come from the server
2) Some data comes from the client (depending on which list of items is selected)
3) The state of some sections of the widget must be remembered when it closes and reopens. 4) The status of other sections must be forgotten and reset to the initial setting
5) The page should be completely displayed very quickly, so AJAX calls must be minimized

So my question is: how do you arrange the code for this widget? Currently, I have sending HTML code for a widget with some data (for example, No. 1) populated on the server side (to avoid sending data through an additional AJAX call). Then I have a bunch of jquery code that fills the client side stuff in a special way. And then another code before reset, everything returns to the desired state on the second call. Surely, is there a more declarative way to do this?

+3
source share
2 answers

, Javascript MVC. , ajax. , , .

.

, . - . , , .

, cachable ajax script . , .

+1

, , GUID/UUID " " ( 13 , - . , .) , serveride clientside. GUID/UUID , - .

" " , javascript ( - , , , ... , , , , )

. .

0

Source: https://habr.com/ru/post/1766261/


All Articles