а

Toolbar "value" with JS variables


#1

I have a function which returns a string from a function. This works well.
I then parse this string to return a new string which I can then output.

I want to display this as my title in the toolbar, however I cannot work out how to write the “value” in the toolbar_data.

table_last_update = getLastUpdate();
last_update_parsed = table_last_update.responseText.substring(table_last_update.responseText.indexOf(":")+2,table_last_update.responseText.indexOf(",")-1)

^ This part works fine

var toolbar_data = [{
id: “refresh”,
value: “Refresh Data”,
type: “button”
},
{
type: “separator”
},
{
type: “title”,
id: “last_update”,
value: “eval(“last_update_parsed”)”
}];

  var toolbar = new dhx.Toolbar("toolbar", {
  	css: "dhx_widget--bordered dhx_widget--bg_gray"
  });	
  
  toolbar.data.parse(toolbar_data);

^ This now errors out, and will not display anything. I can write text in the “value” section and this will display fine, but as soon as I use eval for the variable it fails.

Many thanks,
Ewan


#2

Am I meant to use something like

toolbar_data[“last_update”].appendHTML(“blah”)

or something? The lack of replies on this forum is severely underwhelming. Shows a lack of commitment to a brand new product which doesn’t bode well.


#3

Please, try to use:

{
type: 'title',
id: 'last_update',
value: eval("last_update_parsed")
}

I mean, without the external quotes.