jQWidgets Forums

jQuery UI Widgets Forums General Discussions split javascript file in parts

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 12 years, 11 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • split javascript file in parts #5195

    jmarais
    Participant

    I intend to use tabs with many different parts. Is it possible to split your script handling all these parts into different parts to ease developing and maintenance?

    split javascript file in parts #5218

    Peter Stoev
    Keymaster

    Hi jmarais,

    What do you mean by split javascript file in parts? All widgets are already split into multiple .js files. For example, the Grid comes with modules like jqxgrid.pager.js or jqxgrid.sort.js that enable you to plug-in only the functionality that you intend to use in your app. If you want to load complex content into tabs, you can load it via ajax or you can add iframe within each tab and set the iframe’s src to another web page. This will allow you to separate your app’s logic into multiple files.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    split javascript file in parts #5219

    jmarais
    Participant

    What I meant, is that, say I have 8 tabs, each containing a grid and some other widgets. These grids have edit popups and other additional functionality, making the javascript files long and complex. Now, putting these long and complex code of each tab contents in one file makes it very long and difficult to maintain.

    I looked at your theme roller’s code and seems that you initialise each tab’s content in an additional function. I tried that and it tells me that cannot call jqx for undefined in, for example

    $var dataAdapter = new $.jqx.dataAdapter(source);

    I assume in this case it is not understanding $ and that it can be rectified by ensuring all the necessary files and scripts are called.

    I want to do the same but splitting the javascript for each tab into its own file to make it more easy to develop and maintain. I am still learning javascript and it seems to me that it is not the same type of thing that you have in php, i.e. include or include once.

    I assume that I can continue on the same basis as your example above but I think that a more advance tab example would be beneficial because you do not want to load all tab content at once or every time you click on a tab and the state principle that you use in the theme roller is the right way (making this rather a tab issue).

    split javascript file in parts #5220

    Peter Stoev
    Keymaster

    Hi jmarais,

    As I already written, there are 2 options If you want to load complex content into tabs.

    1. You can load it via ajax – load the content on demand when the user clicks on a tab. The content is loaded from another file.

    2. You can add iframe within each tab and set the iframe’s src to point to another web page. This will allow you to separate your app’s logic into multiple files, too.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.