# Update Sidebar Content

**URL:** <https://discourse.mozilla.org/t/update-sidebar-content/6150>\
**Category:** Development\
**Created:** [December 21, 2015, 1:02pm UTC](https://discourse.mozilla.org/t/update-sidebar-content/6150 "2015-12-21T13:02:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![taibeo1905](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/taibeo1905/32/31015_2.png) [@taibeo1905](https://discourse.mozilla.org/u/taibeo1905)\
**Post date:** [December 21, 2015, 1:02pm UTC](https://discourse.mozilla.org/t/update-sidebar-content/6150/1 "2015-12-21T13:02:54Z")

</div>

How can I change sidebar content with this logic below:

Add-on script: Event occurred =\> page worker creates port.emit

Content script: port.on detected event =\> change sidebar content

Many thanks.

---

<div class="post-metadata">

**Author:** ![pmheil](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/pmheil/32/4049_2.png) [@pmheil](https://discourse.mozilla.org/u/pmheil)\
**Post date:** [January 5, 2016, 6:42pm UTC](https://discourse.mozilla.org/t/update-sidebar-content/6150/2 "2016-01-05T18:42:47Z")

</div>

Try sending another emit from the add-on script to the sidebar script with the requested change.

Example from my extension

sidebar script

> addon.port.emit(“loaded”);  
> addon.port.on(“update”, function(array) {  
> //Make changes using array data  
> });

index.js

> worker.port.on(“loaded”, function() {  
> var theDate = new Date();  
> var endDate = theDate.toJSON();  
> var array = new Array(theDate, endDate);  
> worker.port.emit(“update”, array);  
> });

---

<div class="post-metadata">

**Author:** ![taibeo1905](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/taibeo1905/32/31015_2.png) [@taibeo1905](https://discourse.mozilla.org/u/taibeo1905)\
**Post date:** [January 6, 2016, 2:00pm UTC](https://discourse.mozilla.org/t/update-sidebar-content/6150/3 "2016-01-06T14:00:21Z")

</div>

Hi Paul,

It works perfectly. Thank you.

Regards,

Ken
