6 Replies Latest reply on Nov 21, 2007 10:26 AM by jdemarco1

    Dynamic Links

    Venkat Rao Level 1
      Hi,
      I am trying to build a simple RSS reader. I want to have the title of a post act as a link. This has to allow me to dynamically generate to the text property and click event. However this does not seem to be working.
      Here is my code:


      <mx:Repeater dataProvider="{feed.lastResult.rss.channel.item}">

      <mx:VBox verticalGap="0" backgroundColor="#EEF5EE" borderStyle="outset">
      <mx:LinkButton click="{url}">
      {title}
      </mx:LinkButton>
      </mx:VBox>
      </mx:Repeater>
      Please let me know what I'm doing wrong.

      Venkat Rao
        • 1. Re: Dynamic Links
          chris.huston.t10 Level 3
          You cannot assign the url directly to the click event of the linkButton. You need to use the navigateToURL function:

          <mx:LinkButton click="navigateToURL(new URLRequest({url}), '_blank')">

          Vygo
          • 2. Re: Dynamic Links
            Venkat Rao Level 1
            Thanks for the quick reply
            But I still seem to be getting the error.
            Component may not have both a text and initializer and attributes.

            And Here is my updated code:
            <mx:Repeater dataProvider="{feed.lastResult.rss.channel.item}">


            <mx:VBox verticalGap="0" backgroundColor="#EEF5EE" borderStyle="outset">
            <mx:LinkButton click="navigateToURL(new URLRequest({url}), '_blank')">
            {title}
            </mx:LinkButton>
            </mx:VBox>
            </mx:Repeater>
            • 3. Re: Dynamic Links
              Suren_kancherla
              you want to display the value of the "title" as label to LinkButton? Use label property of LinkButton.

              <mx:LinkButton click="navigateToURL(new URLRequest({url}), '_blank')" label="{title}">
              </mx:LinkButton>
              • 4. Re: Dynamic Links
                Venkat Rao Level 1
                Hi,
                Still get a error message but it is a different one.
                1084: Systax error: expecting colon before right brace
                1084: Systax error: expecting identifier before right brace

                Here is my updated code:
                <mx:Repeater dataProvider="{feed.lastResult.rss.channel.item}">


                <mx:VBox verticalGap="0" backgroundColor="#EEF5EE" borderStyle="outset">
                <mx:LinkButton click="navigateToURL(new URLRequest({url}), '_blank')" label="{title}"/>

                </mx:VBox>
                </mx:Repeater>
                • 5. Re: Dynamic Links
                  chris.huston.t10 Level 3
                  I tested the code below and it worked:

                  <mx:Repeater dataProvider="{feed.lastResult.rss.channel.item}" id="rpt">
                  <mx:VBox verticalGap="0" backgroundColor="#EEF5EE" borderStyle="outset">
                  <mx:LinkButton
                  click="navigateToURL(new URLRequest(event.currentTarget.getRepeaterItem().url), '_blank')"
                  label="{rpt.currentItem.title}"/>
                  </mx:VBox>
                  </mx:Repeater>

                  Vygo
                  • 6. Re: Dynamic Links
                    jdemarco1
                    The example is great! Exactly what I was trying to do, thank you.