Jquery mesh binding

Let's say I have a jquery grid (plugin).

Of course, he has the ability to get data from an ajax source or from another source (client source).

Now let's say that when the page loads, I have to display the initial data (well, not so much data, because I have a pager, but from the second page, etc. the request is called as ajax result)

HOW should I bind the source data (POV design)

I have:

  • In - ASP.net/PHP (on server code) register a boot script client that will run after the page loads (this script will retrieve data using ajax)

(minus: it really will make 1 more request to the server (for data))

  • I could write (with the initial answer) a hidden field in which the json data will be stored (still) when the script registration client starts - and in <Script> - read the data from the hidden field.

  • another variant?

What is the right way to do this?

ps I do not want to put the binding in document.ready , because I believe that it is better to bind data much earlier.

+4
source share
1 answer

I prefer the first approach when the presentation user interface is completely separate from the data source, even if it invokes a second response from the server.

This allows you to completely cache the view; although there are some caching options for fragments on some platforms (for example, ASP.NET), so with a small amount of built-in configuration data, probably not so much.

If you want to restrict callbacks, then the exact same code responsible for generating JSON responses (for calls to the call filtering service on the page or on the server side needed for the grid to work) is used to provide the first page of data embedded in the request page itself.

As a third-party, DataTables supports this feature (embedded data with subsequent requests satisfied by AJAX calls).

0
source

All Articles