0

I have an element on the page, i.e.

I then add the RQB element with:

  RedQueryBuilderFactory.create({targetId:'foo1',
      meta:myMeta,
      onSqlChange:sqlChange,
      onTableChange:tableChange,
      enumerate:enumerate,
      suggest:suggest,
      editors : [ {
          name: 'DATE',
          format : 'dd.MM.yyyy'
      }
                 ]},
      sql,
      args);

I then change the id of the containing div via $('#foo1').attr('id','foo2');

How do I update the targetId in the RQB instance config so that it will also be 'foo2' to that it matches the containing div?

Severun
  • 2,893
  • 1
  • 16
  • 22

1 Answers1

0

I think the targetId is only used once when the widget is setup. The only call to get that value I can find is here: https://github.com/salk31/RedQueryBuilder/blob/master/redquerybuilder-js/src/main/java/com/redspr/redquerybuilder/js/client/RedQueryBuilder.java#L58

Is there a problem after you change the id of the element?

salk31
  • 995
  • 2
  • 8
  • 13
  • The issue I'm trying to solve, is to figure out where RQB is on the page inside of the sqlChange callback. I was using this.targetID inside the callback, but it's incorrect, after I have updated the containing
    . I was looking to change the value when I update the ID of the containing div so I could keep them in sync, but instead I implemented a workaround. What I did was set up a targetId to div/id map, so when I update the div's ID, I keep track of what the original and new values are.
    – Severun Oct 24 '14 at 16:20
  • Ah OK. I think the lack of context for the onSqlChange callback is rather poor. Is on the list of things to fix. – salk31 Oct 24 '14 at 17:39
  • Along similar lines to the Map you could stash the element in the configuration so you could grab it in onSqlChange as this.target ? I'm wondering if it should support passing element (not just id) and in configuration getTarget AND getTargetId would work. – salk31 Oct 26 '14 at 07:55
  • If I added the DOM element to the configuration, it should maintain the thread, so that when queried, the element would have all of it's attributes fresh from the DOM. I think my case might be an edge case, where it wouldn't be used enough to justify extra code to track where it is on the page. – Severun Oct 27 '14 at 19:11