jQuery UI Widgets › Forums › Navigation › Expander › Databinding using jqx-expanded directive
Tagged: Angular, data binding, jqx-expanded, jqxExpander
This topic contains 6 replies, has 3 voices, and was last updated by fritzfrancis 8 years, 4 months ago.
-
Author
-
I currently have a jqxExpander set up using Angular, like this:
<jqx-expander ng-if="locationType.IsLoaded" data-ng-repeat="equipmentType in locationType.EquipmentTypes" jqx-expanded="equipmentType.IsExpanded" jqx-on-expanding="OnEquipmentTypeExpanding(event)"> <div>{{ equipmentType.EquipmentTypeName }}</div> <div>(expander content here)</div> </jqx-expander>
It looks like the
jqx-expanded
directive is not two-way data bound, which creates issues with keeping theexpanded
property and the scope variable in sync. Changing the variable properly expands/collapses the expander, but expanding/collapsing by clicking does not update the variable. In myjqx-on-expanding
function, I have manually added a line of code that explicitly sets theIsLoaded
variable to true, and this seems to work. The problem I can’t fix is when collapsing the expander. I have tried adding the directivejqx-on-collapsed="locationType.IsLoaded = false"
to the element, and that is not working. I’ve also tried it with thecollapsing
event as well. Nothing is working.How can I simply keep the expanded state and the scope variable in sync?
Regards,
Fritz FrancisHi Fritz Francis,
You can use the widget’s Events to know when it is collapsed or expanded either by user or API.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comAs I stated, I have already tried using all four events (
expanded
,expanding
,collapsed
, andcollapsing
) to manually set myIsExpanded
property to eithertrue
orfalse
. Thecollapse
andcollapsing
events are not working. I have triedjqx-on-collapsed="locationType.IsLoaded = false"
, but when I collapse an open expander, I go in and look at theIsExpanded
property, and it’s still set totrue
.Please advise.
Regards,
Fritz FrancisHi Fritz Francis,
To learn how to bind to events, visit the page which explains how to bind to events. The binding which you have now is wrong.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comI understand how to bind events with angular. My
expanded
andexpanding
events work just fine. Please provide a working example, or at least provide more detail than just “the binding which you have now is wrong”.jqx-on-collapsed=”locationType.IsLoaded = false” – such code will not and cannot work. How to bind to events is demonstrated in the examples available online on our website which I suggest you to look at. I see no reason to build a new example when there are multiple already available.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comLooks like I’ll have to get more detailed in order to get any support.
Here’s what my
OnEquipmentTypeExpanding
function looks like.$scope.OnEquipmentTypeExpanding = function (event) { var id = event.data("id"); var equipmentType = $scope.FindEquipmentType(id); equipmentType.IsExpanded = true; };
In my
jqx-expander
element, I’ve added adata-id
field that contains the ID of the particular equipment type expander I’m trying to expand. This is then used to find the right object in my scope and set itsIsExpanded
property to true. This works fine.In addition to the example I’ve sited, I’ve also tried doing the same thing for collapsing, but inversely. In my
jqx-expander
element, I addedjqx-on-collapsing="OnEquipmentTypeCollapsing(event)"
. Here’s what the function looks like:$scope.OnEquipmentTypeCollapsing = function (event) { var id = event.data("id"); var equipmentType = $scope.FindEquipmentType(id); equipmentType.IsExpanded = false; };
I know the issue isn’t with my
FindEquipmentType
function, because it works fine when expanding. Using the Chrome extension ng-inspector, I can see that theIsExpanded
property correctly changes totrue
when expanding, but it does not work when collapsing.Please advise.
-
AuthorPosts
You must be logged in to reply to this topic.