Dynamically change list item

Dynamically change list item

  
Hi

I am using a JQuery menu that is build using an unordered list. Each menu item is in it's own <li>

I have created a web block that contains this html. What I would like to do is dynamically change the menu based on who is loged in. Is this possible?

Thanks
My sugestion is you build the unordered list using the ListRecords control, with LineSeparator set to Bullets. This will create an unordered list inside a span with the id of the ListRecords.
Then modify the initialization script to $('#ListRecords.Id').contents.first().<something> (where <something> is the call to initialize the menu, because $('#ListRecords.Id').contents.first() will return the <ul> element).

By using the ListRecords control you'll be able to modify your layout with ServiceStudio, making your code a lot cleaner than if you inject the <ul> and <li> tags directly.
Thanks, trying that now :)
OK, I followed your advice and managed to get the unformatted menu produced as a UL using the ListRecords control. Thanks for that.

My next question is how can I format it? The menu I have is obviously styled using CSS, in the non dynamic verson I just have html which I can add css classes to the different UL and LI elemend (as well as DIVs and A elements) any idea how I can build these classes into the list dynamically using this method?

Thanks
Hi Martin,
You can place containers (DIVs) inside the List record. and this will make a div apear in all li elements, so you just need to aply the style to that div, if you need diferent styles acording to something, you can use inline style and use the if() function to select the styles that you want to apply on that element.

Regards,
Carlos Rocha
Martin, if you need to set the classes for the <ul> and <li> elements themselves, you can set them with jQuery before you initialize the menu.
Something like:
$('#ListRecords.Id').find('ul').toggleClass('className1')
$('#ListRecords.Id').find('li').toggleClass('className2')
$('#ListRecords.Id').contents.first().<something> <- Menu initialization.

If all you need to edit is the content, follow Carlos sugestion.
Are we stuck with the extra <span> tags?
Thanks for the suggestions but I think I'm going to have to ditch the ListRecords idea and try to accomplish this with an expression as I just can't get the control over the html that I need to make this work.

Very frustrating so far, this week the platform seems to have been slowing down development rather than speeding it up :(
Hi Martin,
I can't be happy when I hear that, maybe if you post here some screenshots or something like that to be easy to understand how you want to format that ( assuming that your problem is the formatation of the elements) it would be easier to point you the right direction.

Regards
Carlos Rocha
Thanks, but I think using the expression will give me better control over the html created and that is what I need.

I have my menu set up again now using expresssions, can you tell me if it's possible to dynamically change the html based on the role? 

e.g

If I have a <li> in the expression, is it possible to use the built in function CheckRegisteredRole to display two different <li> elements depending if the user is logged in or not.
It's OK, managed to figure it out.

It would just be -

" + If (CheckGlobalRegisteredRole(UserId:), "<li>a</li>","<li>b</li>") + "