Page 1 of 2

How to change header text programmatically (or link to a REST output)?

Posted: Thu Jan 26, 2012 10:32 am
by FraserHardy_uk

Is it possible to change the text of the page headers programmatically? Or have them linked to a service output?

Thanks,


How to change header text programmatically (or link to a REST output)?

Posted: Thu Jan 26, 2012 5:54 pm
by maxkatz

Here is how to do it programmatically:

code
($('h1').first().text('New header'));
/code

As for mapping, not yet possible.


How to change header text programmatically (or link to a REST output)?

Posted: Mon Apr 23, 2012 11:49 pm
by Stichoza

How to change text of other page header?


How to change header text programmatically (or link to a REST output)?

Posted: Tue Apr 24, 2012 12:39 am
by maxkatz

What do you mean by "other page header"? What is other?


How to change header text programmatically (or link to a REST output)?

Posted: Mon Jun 25, 2012 9:09 pm
by Claudio

Hi,
if you use navigateTo("second_page","ajax"), and want change the second page's header, the first h1 tag is not the right one.

I use ($('h1[dsid="header_name"]').first().text("new text")) instead.


How to change header text programmatically (or link to a REST output)?

Posted: Thu Mar 28, 2013 3:00 am
by Brian Wente

So I can use this?

($('h1').first().text(categoryName));

On the previous page, I need to set the value of categoryName and store it as a local storage variable.

Then "on load" run the javascript?


How to change header text programmatically (or link to a REST output)?

Posted: Thu Mar 28, 2013 3:31 am
by maxkatz

Yes, looks right.


How to change header text programmatically (or link to a REST output)?

Posted: Thu Mar 28, 2013 3:36 am
by Brian Wente

how does the categoryName or the local storage value get read by the javascript variable?


How to change header text programmatically (or link to a REST output)?

Posted: Thu Mar 28, 2013 3:43 am
by maxkatz

To read from local storage:
localStorage.getItem('key');


How to change header text programmatically (or link to a REST output)?

Posted: Thu Mar 28, 2013 3:48 am
by Brian Wente

Perfect!

($('h1').first().text(localStorage.getItem('categoryName')));

Thanks!