jQWidgets Forums
jQuery UI Widgets › Forums › General Discussions › dynamically load a view
This topic contains 5 replies, has 3 voices, and was last updated by Peter Stoev 9 years, 9 months ago.
-
Authordynamically load a view Posts
-
The structure of my UI is that I have a default tab at the top including add a new tab. Below that, a menu. When the user clicks a tab they can assign content to the tab from the menu item chosen. That might mean they add a grid-based view, or a tree-based view, or a docking panel-based view. So the point is that the user is dynamically creating tabs and then dynamically assigning content – a view – to that tab.
What is the best way to structure the code so that I can achieve that?
Thanks much for any advice.
Hi emberq,
You can use jQuery’s append function to dynamically add HTML Elements to your web page and after you have the HTML Elements on the page, you can initialize the widgets.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hey, thanks – what I’m trying to do is use jqxTabs setContentAt() method and put my jqxGrid there but that tab method is expecting HTML code. So one way to proceed I suppose is to get the HTML associated with my Grid and pass it there. But there does not seem to be a method for getting the entire HTML associated with the Grid. The export only exports row data to HTML.
BTW, if there is a better way for me to do this I’m all ears.
Thank you.
Hi emberq,
setContentAt allows only HTML Strings so it will not help for adding Grids. I still think that jQuery’s append should be used for adding HTML Elements dynamically and then calling the constructor functions for creating the widgets. Also keep in mind that widgets should be initialized from HTML Elements which are in the DOM and which are visible i.e with display: block.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/OK I see that getting the HTML out of the grid and setting it in the tab is not going to work because I think the event handlers are not coming with the HTML.
I need to try your idea for the append but I’m not sure I understand what and how to “initialize” the element in the DOM. Somehow I need to create an empty grid, not have it displayed, and then when I create a new tab have it displayed with all its handlers in that tab.
Thanks for the assistance again.
Hi emberq,
Grids loaded in Tabs on demand actually are demonstrated on: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/tabs-and-grid.htm?arctic
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.