Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Tagfield returns tag string inside a <a> tag with javascript?


Reply

2 Posts   744 Views

Avatar
DsX

30 December 2010 at 8:49am Community Member, 178 Posts

I am using the tagfield as a field in a nested DOM (I have a page with imageResources that have imageDetails).
In the backend everything is good. Tagfield works, everything save, no errors anywhere. DataModel appears to be good.

In the templates, I return a imageResource from a getter that looks it up by ID, I can them control thru imageDetails and I can display my 3 elements (Role, URL, Name)
Role is a enum, and URL and Name both use tagfield.
If I only wish to display the Role, everything is great.
When I try to out either $URL or $Name, I get something like:

<ul id="Menu1">
<li onclick="location.href = this.getElementsByTagName('a')[0].href"><a href="">FirstName </a></li>
<li onclick="location.href = this.getElementsByTagName('a')[0].href"><a href="">LastName</a></li>
</ul>

The text in the anchor in the List item is the text I expect, the rest of the HTML/javascript not.
In the case above there are 2 list items, this is because when entering the Name it gave me 2 tags in the tag field, where I would Ideally see "FirstName LastName".
URL is returning the same, but with a single List item.

Looking at the table in the database I see that the stored data is the simple Varchar strings. eg: 'FirstName'

So is there a way to get the clean string data eg: 'FirstName LastName' returned in my control?

Avatar
DsX

30 December 2010 at 9:15am Community Member, 178 Posts

Solved it..

can't believe this stumped me for so long ;)

You need to control through the associated Tagfields inside the context of the class that contains them.

I think that fact that I was getting something was messing with me, at first I though it was being created live by Javascript..

anyway, as a side effect I see how to create a list of associated tags like a tag cloud, however I do not know how to set the URL for the links??

any additional help would be great.