Track another widget's events

3317
3
Jump to solution
11-10-2015 02:38 PM
AnthonyPreston1
New Contributor

Still fairly new to WAB, and dojo on the whole, so perhaps this has a simple answer.

Take, for example, the out-of-the-box version 1.2 Search widget. Inside its .js file is the following few lines:

              this.own(

                on(this.searchDijit, 'select-result', lang.hitch(this, '_onSelectResult'))

              );

I'm wondering if there's away to hitch on to this exact same event from another custom non-panel widget. The desired behavior is that whenever the out-of-the-box Search widget's searchDigit fires its 'select-result' event, this other custom widget can perform an action as well, using the same argument object that is passed to the local Search's event handler.

I'm trying to avoid modifying the out-of-the-box Search widget's code, as it seems pretty tightly coupled to the WAB layout. Though if there are any best practices for this latter approach, I'm open to those as well.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Anthony,

   Sure you can all you need to do is get a reference to the search widget object using WidgetManager and then you will have access to the this.searchDijit and you can attach as many event listeners as you want to the 'select-result'.

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Anthony,

   Sure you can all you need to do is get a reference to the search widget object using WidgetManager and then you will have access to the this.searchDijit and you can attach as many event listeners as you want to the 'select-result'.

0 Kudos
AnthonyPreston1
New Contributor

I had a feeling this'd be the case, thanks. Just wasn't sure if I'd be able to access the .searchDijit that way.

0 Kudos
SumathyAlwar_Arunachalam1
New Contributor

Hi , I'm wondering did you ever find a way to get this searchDijit from WidgetManager instance.I got till the search Widget , but couldnt get to the searchDijit from that. I'm stuck currently. 

0 Kudos