For Glass.Mapper BeginRenderLink described as method to render a link that should contain multiple HTML elements: http://glass.lu/docs/tutorial/sitecore/tutorial22/tutorial22.html
What I'd like to add is custom attributes (class, style) to that link:
<% using (BeginRenderLink(x => x.Image1Link,
new NameValueCollection
{ { "class", "image-banner" }, { "style", string.Format("background-image: url({0})", Model.Image1.Src) } }, true))
{ %>
<span class="image-banner-wrapper">
<span class="image-banner-content"><%= Editable(x => x.Image1Text) %></span>
</span>
<% } %>
This additional attributes works fine in normal mode but are not displayed in editing mode.
Here is what was found in Glass.Mapper sources for BeginRenderLink:
if (IsInEditingMode && isEditable)
{
return MakeEditable(field, null, model, "haschildren=true", _context, SitecoreContext.Database, writer);
}
else
{
return BeginRenderLink(field.Compile().Invoke(model) as Fields.Link, attrs, string.Empty, writer);
}
So if it is editing mode, no additional attributes are applied, only "haschildren=true" is passed.
I wonder is anybody solve that issue somehow?