jQuery UI Widgets › Forums › Layouts › DockPanel › Calling jqxDockPanel on Dynamic Content
Tagged: dockpanel
This topic contains 3 replies, has 2 voices, and was last updated by support 10 years, 3 months ago.
-
Author
-
Hello,
I’m currently experiencing some problems getting jqxDockPanel to work on content that is dynamically loaded after the initial page has loaded.
I’ve been spending some time debugging, and it appears that in jqx.jqxWidgetProxy the method a.data() returns undefined. This leads me to believe that some initialization has not been performed on the element.
Is there a method that I should call on dynamic content to ensure it is properly initialized for jqWidgets?
Thank you for any assistance,
MichaelHi Michael,
Could you please provide us with a sample which demonstrates with a scenario.
Best Wishes,
MariyajQWidgets Team
http://www.jqwidgets.comHi Mariya,
Sorry for the delay. If you look at the demos/jqxdockpanel/defaultfunctionality.html in your current release, and change its document.ready function to the following, you’ll see what i’m talking about:
$(document).ready(function () {
// Create jqxDockPanel
var theme = $.data(document.body, ‘theme’);
if (theme == null || theme == undefined) theme = ”;
var panel = $(“#jqxDockPanel”);
panel.remove();
$(“#jqxDockPanel”).jqxDockPanel({ width: 300, height: 210, theme: theme });
panel.prependTo($(“#jqxWidget”));
—It appears that elements require to be part of the visible element tree in order for the jqxWidget extension methods to work as expected. If you can imagine using a templated mvvm framework such as Knockout (or Durandal, in my case), you can see where this might cause problems, as script is being executed when a file loads, but the elements that the script is executing against haven’t necessarily been appended to the visual element tree when this occurs.
Hope this helps,
MichaelHi Michael,
$(“#jqxDockPanel”) will not work if the DIV tag with id=”jqxDockPanel” is not part of the DOM. As no HTML element is selected, the initialization of the widget will not work in this case, too.
Best Wishes,
MariyajQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.