# Pass messages to UI template using Jquery

**URL:** <https://discourse.nodered.org/t/pass-messages-to-ui-template-using-jquery/77938>\
**Category:** Dashboard\
**Created:** [26 April 2023 01:54 UTC](https://discourse.nodered.org/t/pass-messages-to-ui-template-using-jquery/77938 "2023-04-26T01:54:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mick](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mick/32/80990_2.png) [@Mick](https://discourse.nodered.org/u/Mick)\
**Post date:** [26 April 2023 01:54 UTC](https://discourse.nodered.org/t/pass-messages-to-ui-template-using-jquery/77938/1 "2023-04-26T01:54:33Z")

</div>

I am using a UI Template node to to a scope watch to update changes for display. I am currently using this code:

```auto
<script>
    (function(scope) {
        //hide this card. NOTE: 4b689f7473831a84 is the Node id as 
        //seen in the INFO panel on the sidebar when you select this node
        $('[node-id="55ef921cfa9dc9cd"]').hide();
        scope.$watch('msg', function(msg) {
            if (msg.topic == "wx") {
                $("#header-thermometer").html("<i class='fa fa-thermometer-half' aria-hidden='true'></i>").css("color",'#98FF55');
                $("#header-temperature").text(msg.temp);
                $("#header-wdirection").html(msg.windir).css("color",'#A6EDF8');
                $("#header-wspeed").text(msg.speed);
                $("#header-wicon").html(msg.wxicon).css("color",'#FBFCB8');
                $("#header-wbar").html(msg.bar).css("color",'#B6B8E2');
            }
        });
    })(scope);
</script>

```

The only way I could pass a message to the Jquery was by using above format. If I tried to type a command such as:

```auto
<i class="wi wi-direction wi-from-{{msg.windir}} wi-1x" style="color:#A6EDF8";>&nbsp</i>

```

The message was not picked up.. I ended up coding the entire html line as a msg object. The html format works if I hard code the value and use it instead of the .html(msg.object). Is there a way to embed the message in a Jquery html statement?

Regards

---

<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:** [26 May 2023 01:55 UTC](https://discourse.nodered.org/t/pass-messages-to-ui-template-using-jquery/77938/2 "2023-05-26T01:55:11Z")

</div>

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