Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get parent text during on-change/selected event #49

Open
nmz787 opened this issue Mar 14, 2022 · 0 comments
Open

get parent text during on-change/selected event #49

nmz787 opened this issue Mar 14, 2022 · 0 comments

Comments

@nmz787
Copy link

nmz787 commented Mar 14, 2022

I needed to get the parent text during the onChange event, so hacked the code using:

--- C:\git\combo-tree\comboTreePlugin.js	2022-03-14 16:43:17.000000000 -0700
+++ C:\git\myApp\static\Drop-Down-Combo-Tree\comboTreePlugin.js	2022-03-11 14:46:57.000000000 -0700
@@ -323,13 +323,15 @@
       return false;
     }
 
     if ($(ctItem).data("selectable") == true) {
       this._selectedItem = {
         id: $(ctItem).attr("data-id"),
-        title: $(ctItem).text()
+        title: $(ctItem).text(),
+        obj:$(ctItem),
+        parent: $(ctItem).closest('.ComboTreeItemParent').children('.comboTreeItemTitle')
       };
 
       let check = this.isItemInArray(this._selectedItem, this.options.source);
       if (check) {
         var index = this.isItemInArray(this._selectedItem, this._selectedItems);
         if (index) {
@@ -344,13 +346,15 @@
   };
 
   ComboTree.prototype.singleItemClick = function (ctItem) {
     if ($(ctItem).data("selectable") == true) {
       this._selectedItem = {
         id: $(ctItem).attr("data-id"),
-        title: $(ctItem).text()
+        title: $(ctItem).text(),
+        obj:$(ctItem),
+        parent: $(ctItem).closest('.ComboTreeItemParent').children('.comboTreeItemTitle')
       };
     } // if selectable
 
     this.refreshInputVal();
     this.closeDropDownMenu();
   };
@@ -404,13 +408,13 @@
     }
 
     this._elemInput.val(tmpTitle);
     this._elemInput.trigger('change');
 
     if (this.changeHandler)
-      this.changeHandler();
+      this.changeHandler(this);
   };
 
   ComboTree.prototype.dropDownMenuHover = function (itemSpan, withScroll) {
     this._elemItems.find('span.comboTreeItemHover').removeClass('comboTreeItemHover');
     $(itemSpan).addClass('comboTreeItemHover');
     this._elemHoveredItem = $(itemSpan);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant