# Button in title bar

**URL:** <https://discourse.nodered.org/t/button-in-title-bar/33229>\
**Category:** Dashboard\
**Created:** [23 September 2020 13:18 UTC](https://discourse.nodered.org/t/button-in-title-bar/33229 "2020-09-23T13:18:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unsumplex](https://avatars.discourse-cdn.com/v4/letter/u/da6949/32.png) [@unsumplex](https://discourse.nodered.org/u/unsumplex)\
**Post date:** [23 September 2020 13:18 UTC](https://discourse.nodered.org/t/button-in-title-bar/33229/1 "2020-09-23T13:18:43Z")

</div>

Hello, I am trying to create buttons in the title bar that will send a msg on click.  
I am using an ui\_template and creating the button is no problem.  
I am failing on sending the msg on click, here is my code in the ui\_template:

```auto
<script>
    var nodes = document.createElement('BUTTON');
    nodes.addEventListener('click', this.scope.send({payload: "test"}));
    nodes.innerHTML = 'NODES';
    var titleBar = document.getElementById("nr-dashboard-toolbar");
    titleBar.appendChild(nodes);
</script>

```

I tried different approaches but none worked. Does someone have experience with this?  
I am thankful for any hint.

---

<div class="post-metadata">

**Author:** ![unsumplex](https://avatars.discourse-cdn.com/v4/letter/u/da6949/32.png) [@unsumplex](https://discourse.nodered.org/u/unsumplex)\
**Post date:** [23 September 2020 13:34 UTC](https://discourse.nodered.org/t/button-in-title-bar/33229/2 "2020-09-23T13:34:58Z")

</div>

Well I got it working with some adjustments just some minutes after creating the thread... tried for hours before.

```auto
<script>
    var theScope = scope;
    
    var nodes = document.createElement('BUTTON');
    nodes.addEventListener('click', sendPayload);
    nodes.innerHTML = 'NODES';
    var titleBar = document.getElementById("nr-dashboard-toolbar");
    titleBar.appendChild(nodes);
    
    function sendPayload(){
        theScope.send("1");
    }
</script>

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 October 2020 13:35 UTC](https://discourse.nodered.org/t/button-in-title-bar/33229/3 "2020-10-07T13:35:13Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
