Mark Logan
Mark Logan

Reputation: 123

How to change dojo/dijit tab title programmatically?

For example, given the dijit.ContentPane tab below, how do I programmatically change the title "Summary" to something else?

<div id="summaryContent" class="tabClass" dojoType="dijit.layout.ContentPane" title="Summary" selected="true">

I tried:

dojo.byId('summaryContent').title
document.getElementById('summaryContent').style.title

...as well a bunch of other combinations, but it doesn't work? Any ideas?

Upvotes: 5

Views: 5828

Answers (3)

Darrel K.
Darrel K.

Reputation: 1729

This is what worked for me, not only for title but for any property:

First include "dijit/registry" (https://dojotoolkit.org/reference-guide/1.10/dijit/registry.html)

Then in code do:

var summaryContent = registry.byId("summaryContent");
summaryContent._set("title", "new title here");
//Set something like the icon
summaryContent._set("iconClass", "summary-icon");

Upvotes: 0

Bibhuti Ojha
Bibhuti Ojha

Reputation: 1

  1. Get the instance of the div by using "dijit.byId".
  2. As you have created the instance by using dijit ("dijit.byId"), so use the method 'set' to set the value to the property.

Code: dijit.byId("summaryContent").set("title", "New Title");

*New Title: is the title which you want to set.

Upvotes: -1

Frode
Frode

Reputation: 5710

Just two small mistakes: first, to get a dijit instance (e.g. the dijit.layout.ContentPane javascript object, not the DOM node) you have to use dijit.byId, and secondly, setting a property on a dijit is done with the set method. So:

dijit.byId("summaryContent").set("title", "My new awesome title");

.. should do the trick.

Upvotes: 10

Related Questions