Hi,
I'm trying to extent the LayerList widget as a means to reuse preferred settings/code between projects. The trouble I'm having is in implementing the trigger-action handler. I have ported the code from the sample. It worked fine outside of my widget extension, so It's likely a matter of scope, but I can't figure out how to change it.
I'm writing my widget in TypeScript.
In postInitialize, I'm setting up the list item actions, and they seem to work. But on click, the event coming through to _triggerAction doesn't have event.item. I noticed it is of type "click". Might be a clue as to what is going on??
relevant bits:
<SPAN class="token function">postInitialize</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> defineActions <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>_defineActions<SPAN class="punctuation token">.</SPAN><SPAN class="token function">bind</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>listItemCreatedFunction <SPAN class="operator token">=</SPAN> defineActions<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> triggerAction <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>_triggerAction<SPAN class="punctuation token">.</SPAN><SPAN class="token function">bind</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">on</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"trigger-action"</SPAN><SPAN class="punctuation token">,</SPAN> triggerAction<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">private</SPAN> <SPAN class="token function">_triggerAction</SPAN><SPAN class="punctuation token">(</SPAN>event<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> layer <SPAN class="operator token">=</SPAN> event<SPAN class="punctuation token">.</SPAN>item<SPAN class="punctuation token">.</SPAN>layer<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> id <SPAN class="operator token">=</SPAN> event<SPAN class="punctuation token">.</SPAN>action<SPAN class="punctuation token">.</SPAN>id<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">switch</SPAN> <SPAN class="punctuation token">(</SPAN>id<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">case</SPAN> <SPAN class="string token">"full-extent"</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>view<SPAN class="punctuation token">.</SPAN><SPAN class="token function">goTo</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">.</SPAN>fullExtent<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">break</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">case</SPAN> <SPAN class="string token">"information"</SPAN><SPAN class="punctuation token">:</SPAN>
window<SPAN class="punctuation token">.</SPAN><SPAN class="token function">open</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">.</SPAN>url<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">break</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">case</SPAN> <SPAN class="string token">"increase-opacity"</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">.</SPAN>opacity <SPAN class="operator token"><</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
layer<SPAN class="punctuation token">.</SPAN>opacity <SPAN class="operator token">+</SPAN><SPAN class="operator token">=</SPAN> <SPAN class="number token">0.25</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">break</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">case</SPAN> <SPAN class="string token">"decrease-opacity"</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">.</SPAN>opacity <SPAN class="operator token">></SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
layer<SPAN class="punctuation token">.</SPAN>opacity <SPAN class="operator token">-</SPAN><SPAN class="operator token">=</SPAN> <SPAN class="number token">0.25</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>I'm using JS API 4.11.
Ideas?
Liz