Loading ...
Sorry, an error occurred while loading the content.

Re: Menu driven by dynamic callback

Expand Messages
  • an0n73
    I ve found that if I replace the JSON.parse(...) method with eval(...) then my it all works fine for a format of: [{text: Test1 ,url: www.d.com }] Reading
    Message 1 of 6 , Dec 9, 2009
    • 0 Attachment
      I've found that if I replace the JSON.parse(...) method with
      eval(...) then my it all works fine for a format of:
      "[{text:'Test1',url:'www.d.com'}]"

      Reading the JSON information, I'm informed that using eval(..) is unsafe but it's the only thing that works. How can I get it to work without the use of eval(..)?

      --- In ydn-javascript@yahoogroups.com, "an0n73" <an0n73@...> wrote:
      >
      > Hi Todd,
      >
      > One more question...
      >
      > I've changed your sURL page to my own getMenuData.jsp page and all this page contains as a test is what I believe to be the correct format of a JSON string however it clearly isn't correct as when it's returned and the JSON.parse method is used on the reponseText it throws an error.
      > I've tried various string formats but none of them work:
      > "[{text:'Test1',url:'www.d.com'}]"
      > or
      > "[{id: 'communication',itemdata:[{text:'Test1',url:'www.d.com'}]}]"
      >
      > Can you tell me what format is expected back in the responseText?
      >
      > Thanks
      >
      > --- In ydn-javascript@yahoogroups.com, "an0n73" <an0n73@> wrote:
      > >
      > > Hi,
      > >
      > > I'd like to create a MenuBar in which the subMenu's within each menu are driven by a connection manager callback function.
      > > My experience with YUI isn't extensive so I'm hoping for some guidance.
      > >
      > > Taking one of the examples, I have the following which works:
      > >
      > > Markup is:
      > > ...
      > > <div class="bd"><ul class="first-of-type">
      > > <li class="yuimenubaritem first-of-type">
      > > <a class="yuimenubaritemlabel" href="#communication">Communication</a></li>
      > > ...
      > > and the javascript is:
      > > ...
      > > var oMenuBar = new ...
      > > var data = "[{id: 'communication',itemdata[{text:'360',url:....etc}]";
      > > var aSubmenuData = eval(data);
      > > oMenuBar.subscribe("beforeRender", function() { .....
      > > <rest of example>
      > >
      > > What I'm think is that what I need is to basically replace the line
      > > var data = "[{id: 'communiction' ....
      > > with a callback function so that this variable data is populated from the results of the callback function.
      > >
      > > My questions are:
      > > - would this work?
      > > - if so, how do I setup the callback function in high level terms, would the function be within the existing onContentReady event or external and if so how do I assign the Response object data back to my variable?
      > >
      > > Any help would be appreciated.
      > >
      > > Thanks
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.