1

I've been using jQuery-QueryBuilder to implement an Advanced Search feature in my Rails app. It's cool.

Right now, I want to customize the templates by adding a new Add group called Add Custom Group as my screenshot.

enter image description here

The behavior of Add Custom Group button is almost the same Add group button, but I will have some more logic to add default filters when that button is clicked.

I'm debugging in this callback now, beforeAddGroup.queryBuilder(event, object). However, when I do object.$el or event.target, I get the whole div element that contains everything as you can see in the screenshot and that's why I cannot find a way to see which group button is clicked yet.

In short, my objective is to know which group button is clicked whether it is either Add group or Add Custom Group.

Please feel free to let me know if further detail is required and would help you identify my issue and we can find the solution.

Pirun Seng
  • 443
  • 1
  • 4
  • 20

1 Answers1

0

Try using the afterAddGroup event to add onclick events to your group buttons. Save the value of the clicked button for use in your other events. See on how to save value: jQuery how to get the class or id of last clicked element?

Jeremy Ray Brown
  • 1,499
  • 19
  • 23