Announcement

Collapse
No announcement yet.

data-toggle data-parent, etc

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    data-toggle data-parent, etc

    Hey guys,

    I just started using Bridge.net and, right now, as an exercise, I'm porting a website from html to C#.

    The html looks like:

    HTML Code:
    <a data-toggle="collapse" data-parent="#accordion" href="c">Collapsible Group 1</a>
    My doubt is: how do I "translate" the "data-toggle" and "data-parent" to C#, using a HTMLAnchorElement?

    Sorry for the question, but I couldn't find a solution online.

    Thanks,
    Nícolas

    #2
    Hi Nicolas

    That should be quite easy to accomplish:
     AnchorElement el = new AnchorElement()
     {
         Href = "c",
         InnerHTML = "Collapsible Group 1"
     };
     el.SetAttribute("data-toggle", "collapse");
     el.SetAttribute("data-parent", "#accordion");
    
     //Then append the new element somewhere in the DOM:
     Document.Body.AppendChild(el);
    Hope this helps.
    Marco

    Comment


      #3
      Just a small note about the Marco sample. As of Bridge 1.14, AnchorElement has been renamed to HTMLAnchorElement.

      Here's the sample in Live Bridge:

      http://live.bridge.net/#14cfc617e3d0...35b564e59d1a4e

      Hope this helps.

      Comment


        #4
        This works perfectly fine!

        Thanks, geoffrey.mcgill and Marco!

        Comment

        Working...
        X