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

Re: the MENU data can pump in by using xml file ?

Expand Messages
  • alexshusta
    Hi yoonfui83, JSON == JavaScript Object Notation. The file that you load will be a regular JavaScript file with the contents being in JSON format. You ll load
    Message 1 of 6 , Apr 30, 2007
    • 0 Attachment
      Hi yoonfui83,

      JSON == JavaScript Object Notation.

      The file that you load will be a regular JavaScript file with the contents being in JSON format. You'll load the file using a <script> tag, just like any other JavaScript file.


      <script src="yoonfuiMenu.js"></script>

      The documentation at JSON.org is quite good, and they have translations  of many pages into languages besides English (Chinese , Czech, French , German , Japanese , Korean , etc.).

      Your file will end up looking like:


      yoonfuiMenu = {
          Items:
      [
              { text:"Yahoo! Mail", url:"http://mail.yahoo.com" },
      { text:"Yahoo! Address Book", url:"http://addressbook.yahoo.com" },
      { text:"Yahoo! Calendar", url:"http://calendar.yahoo.com" },
      { text:"Yahoo! Notepad", url:"http://notepad.yahoo.com" }
      ]
      }

      And you'll make reference to the loaded menu object in your page just like in the YUI menu examples except that where the example had a hard-coded array, you put a reference to your JSON object:
              <script type="text/javascript">
      YAHOO.example.onDOMReady = function(p_sType) {
      var oMenu = new YAHOO.widget.Menu("basicmenu", { fixedcenter: true });
      oMenu.addItems(yoonfuiMenu.Items);
      oMenu.render(document.body);
      oMenu.showEvent.subscribe(function() {
      this.focus();
      });

      oMenu.show();
      YAHOO.util.Event.addListener("menutoggle", "click", oMenu.show, null, oMenu);
      };
      YAHOO.util.Event.onDOMReady(YAHOO.example.onDOMReady);
      </script>

      Hope that helped.
      ~Alexander


      --- In ydn-javascript@yahoogroups.com, "yoonfui83" <yoonfui83@...> wrote:
      >
      >
      > hi,
      >
      > any import i need to do if i choose to use JSON?
      > how to read a .json file from fs ?
      > how to implement json into my YUI - menu?
      >
      > pls provide some reference. first time study JSON?
      > now do R & D for JSON.
      > thanks
      >
      >
      >
      >
      >
      > --- In ydn-javascript@yahoogroups.com, Appasamy T appasamy_t@
      > wrote:
      > >
      > > ok write code as follows
      > >
      > > var oMenuBar = new YAHOO.widget.MenuBar("menubar", {
      > autosubmenudisplay:true,lazyload:true,clicktohide: false});
      > >
      > > //some loop
      > > ......................
      > > .................
      > > var menuitem = document.getElementById("something");
      > > oMenuBar.addItem(menuitem );
      > > //end loop
      > >
      > >
      > > Java JSON parser available in JSON.org use it and convert XML to
      > JSON using ajax call and return it back and use it if you want
      > complete menu with sub menu items defined in XML.But its tedious .
      > >
      > > Keep a .json file instead of .xml file and read it and provide
      > JSON format iteself in to the addItems().
      > > It reduces all ur XML parsing tasks and all. Also it provides good
      > readability.
      > >
      > > Regards
      > > T.Appu
      > >
      > >
      > > yoonfui83 yoonfui83@ wrote:
      > hi,
      > >
      > > static menu but while page laoding the js will call the xml and
      > write
      > > out the menu data list .
      > >
      > > --- In ydn-javascript@yahoogroups.com, Appasamy T <appasamy_t@>
      > > wrote:
      > > >
      > > > Hi yoon,
      > > >
      > > > Are u going to use Ajax call to dynamcially update
      > the
      > > menu on each click or just static menu while page loading from an
      > XML
      > > located somewhere?
      > > >
      > > > everthing is possible. Please tell your requirement clearly
      > > >
      > > >
      > > >
      > > >
      > > > yoonfui83 <yoonfui83@> wrote:
      > > hi,
      > > >
      > > > i am figuring out the menu's data can pump in by using XML
      > file ?
      > > cause
      > > > i need real time updating for my menu.
      > > >
      > > > currently im using js and hardcoded in my jsp file there . it
      > it
      > > not
      > > > real life and big problem if come to real life update.
      > > >
      > > >
      > > >
      > > >
      > > >
      > > >
      > > > ---------------------------------
      > > > SHOUT IT OUT! Tell everyone, from anywhere, that you're online
      > on
      > > Yahoo! Messenger
      > > >
      > >
      > >
      > >
      > >
      > >
      > >
      > > ---------------------------------
      > > SHOUT IT OUT! Tell everyone, from anywhere, that you're online on
      > Yahoo! Messenger
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.