1 Reply Latest reply on Sep 9, 2010 5:07 AM by Rieps

    Problems with generated Links (Javascript)




      I just started developing with adobe air and are now facing a strange problem. I use Prototype and Scriptaculous as Javascript Framework. The application communicates with a Server via air.URLRequest and air.URLLoader. Depending on the result of the requests <a>-elements must be created which call javascript-functions. However those generated anchors dont work. There are 2 anchor-elements which are created before the first Request which work fine.

      The other generated ones are displayed and correctly appended to the DOM, but do not work (they just make the window jump back to the top, like href="#" normally does).



      <A onclick="showDetails(188); return false;" href="#">test123</A>           //generated after Request, does not work
      <A onclick="startSearch(); return false;" href="#"><IMG ...></IMG></A>  //generated before Request, works


      Note: The same Javascript is used to create and append the links in both cases.


      Thank you in advance,


        • 1. Re: Problems with generated Links (Javascript)
          Rieps Level 1

          Hey again,

          i'm sorry if pushing a thread up is not allowed.


          I still couldn't figure out a way to get things working. I created a little example to illustrate the problem:


                  <title>Example for non working links</title>
                  <link href="sample.css" rel="stylesheet" type="text/css"/>
                  <script type="text/javascript" src="lib/air/AIRAliases.js"></script>
                  <script type="text/javascript" src="lib/air/AIRIntrospector.js"></script>
                  <script type="text/javascript" src="lib/air/AIRLocalizer.js"></script>
                  <script type="text/javascript" src="lib/air/AIRSourceViewer.js"></script>
                    <script type="text/javascript" src="lib/prototype/prototype.js"></script>
                  <script type="text/javascript">
                         function createLink() {
                              var link = "<a href='#' onclick='saySomething()'>New Link</a>";
                         function saySomething() {
                   <div id="myID">
                   <script type="text/javascript">
                  <button onclick="createLink()">Create new Link</button>


          The first Link called New Link works, all others which are created by clicking on the button dont.

          I guess this has something to do with security restrictions, does somebody have an idea for a workaround? I would really appreciate that.