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

Evaluation of YAHOO object paths from arguments

Expand Messages
  • DL
    From this example of OverlayManager ... http://developer.yahoo.com/yui/examples/container/overlay-manager.html I am trying to extract the javascript for
    Message 1 of 7 , Oct 1, 2006
    • 0 Attachment
      From this example of OverlayManager ...


      I am trying to extract the javascript for launching a number of dynamic containers,
      through a function which receives arguments such as "id", "x", "y").


      But if I turn this code into a function ..

      dynamicOverlay ("oDynamic"); // create dynamic container id="oDynamic"

      function dynamicOverlay (div_id) {

      // script for dynamic creation of container goes here

      }

      how do I convert javascript lines such as ..

      YAHOO.example.overlaymanager. oDynamic  = new YAHOO.widget.Overlay( "oDynamic" , {visible:true, x:400, y:250} );

      into this ..

      YAHOO.example.overlaymanager. div_id  = new YAHOO.widget.Overlay (eval('\"' +div_id+ '\"') , {visible:true, x:400, y:250} );

      i.e dynamically evaluate the object path "YAHOO.example.overlaymanager. oDynamic " throughout the function.

      ....

      The right side of the javascript works .. evaluating "div_id" argument ..

      new YAHOO.widget.Overlay (eval('\"' +div_id+ '\"') , {visible:true, x:400, y:250} );

      ...
      .
      but the left side of the script does not accept "div_id" instead of "oDynamic"

      YAHOO.example.overlaymanager. div_id  =

      this script error is generated  ..

      'YAHOO.example.overlaymanager.oDynamic'  is null or not an object

      ....

      I just need some tips on how  to concatenate an argument ("div_id") into the YAHOO object paths

      'YAHOO.example.overlaymanager.'  +div_id = new YAHOO.widget.Overlay( eval('\"' +div_id+ '\"') , {visible:true, x:400, y:250} );

      and also these lines to change ..
      YAHOO.example.overlaymanager. oDynamic .setHeader("Completely dynamic overlay");
      YAHOO.example.overlaymanager. oDynamic .setBody("I was created completely at runtime!");
      YAHOO.example.overlaymanager. oDynamic .setFooter("dynamic footer");
      YAHOO.example.overlaymanager. oDynamic .render(document.body);

      Thanks

      DL
       
    • DL
      ... After posting my question I found the answer .. use square bracket notation in building object paths from passed arguments in function ..
      Message 2 of 7 , Oct 1, 2006
      • 0 Attachment
        On 1 Oct 2006 at 19:23, DL wrote:

        > I just need some tips on how  to concatenate an argument ("div_id") into the YAHOO object paths

        After posting my question  I found the answer ..  use square bracket notation in building object paths from passed arguments in function ..


        so if "div_id"  is the argument, I can use ..

        YAHOO.example.overlaymanager [div_id]   .. note no dot

        instead of ..

        YAHOO.example.overlaymanager .oDynamic


        DL
      • jfasaldarriaga
        Well, Im doing that but because I ll ready have the dates (from the DB), but my question is, doing something like that, a button with an onClick property that
        Message 3 of 7 , Oct 2, 2006
        • 0 Attachment
          Well, Im doing that but because I'll ready have the dates (from the
          DB), but my question is, doing something like that, a button with an
          onClick property that select all the dates on the current month, it's
          that posible ?

          Thx for your answer.

          --- In ydn-javascript@yahoogroups.com, Eric Miraglia <miraglia@...> wrote:
          >
          > jfasaldarriaga,
          >
          > The easiest way to select all the dates of a month is to do so when
          > you create your calendar instance. Here is code that would create a
          > calendar with every date in October selected:
          >
          > <div id="calendar"></div>
          >
          > <script>
          > var myCal = new YAHOO.widget.Calendar("calendarEl",
          > "calendar","10/2006","10/1/2006-10/31/2006");
          > myCal.Options.MULTI_SELECT = true;
          > myCal.render();
          > </script>
          >
          > Once the Calendar instance has been created, you can select dates
          > using the select method, which takes as its argument a date string or
          > one or more Date objects. See the documentation for this method for
          > more on how to use it. Note that you need to render after using select.
          >
          > Regards,
          > Eric
          >
          >
          > ______________________________________________
          > Eric Miraglia
          > Yahoo! Presentation Platform Engineering
          >
          >
          >
          > On Sep 29, 2006, at 12:47 PM, jfasaldarriaga wrote:
          >
          > > Can I made a function to select all days of a month ? I mean without
          > > any manipulation of the calendar.js ?
          > >
          > >
          > >
          >
        • Eric Miraglia
          jfasaldarriaga, As I mentioned in my previous note, it is indeed possible to select dates scriptologically using your Calendar instance s select method. Here
          Message 4 of 7 , Oct 2, 2006
          • 0 Attachment
            jfasaldarriaga,

            As I mentioned in my previous note, it is indeed possible to select dates scriptologically using your Calendar instance's select method.

            Here is an example that does what you're inquiring about — selects all the days of the current based on a click event:


            Regards,
            Eric

            ______________________________________________
            Eric Miraglia
            Yahoo! Presentation Platform Engineering



            On Oct 2, 2006, at 12:04 PM, jfasaldarriaga wrote:

            Well, Im doing that but because I'll ready have the dates (from the
            DB), but my question is, doing something like that, a button with an
            onClick property that select all the dates on the current month, it's
            that posible ?

            Thx for your answer.

            --- In ydn-javascript@yahoogroups.com, Eric Miraglia <miraglia@...> wrote:
            >
            > jfasaldarriaga,
            >
            > The easiest way to select all the dates of a month is to do so when
            > you create your calendar instance. Here is code that would create a
            > calendar with every date in October selected:
            >
            > <div id="calendar"></div>
            >
            > <script>
            > var myCal = new YAHOO.widget.Calendar("calendarEl",
            > "calendar","10/2006","10/1/2006-10/31/2006");
            > myCal.Options.MULTI_SELECT = true;
            > myCal.render();
            > </script>
            >
            > Once the Calendar instance has been created, you can select dates
            > using the select method, which takes as its argument a date string or
            > one or more Date objects. See the documentation for this method for
            > more on how to use it. Note that you need to render after using select.
            >
            > Regards,
            > Eric
            >
            >
            > ______________________________________________
            > Eric Miraglia
            > Yahoo! Presentation Platform Engineering
            >
            >
            >
            > On Sep 29, 2006, at 12:47 PM, jfasaldarriaga wrote:
            >
            > > Can I made a function to select all days of a month ? I mean without
            > > any manipulation of the calendar.js ?
            > >
            > >
            > >
            >


          • jfasaldarriaga
            Thx Eric for your help :)
            Message 5 of 7 , Oct 3, 2006
            • 0 Attachment
              Thx Eric for your help :)

              --- In ydn-javascript@yahoogroups.com, Eric Miraglia <miraglia@...> wrote:
              >
              > jfasaldarriaga,
              >
              > As I mentioned in my previous note, it is indeed possible to select
              > dates scriptologically using your Calendar instance's select method.
              >
              > Here is an example that does what you're inquiring about — selects
              > all the days of the current based on a click event:
              >
              > http://yuiblog.com/sandbox/yui/v0113/examples/calendar/
              > select_dates_by_script.php
              >
              > Regards,
              > Eric
              >
              > ______________________________________________
              > Eric Miraglia
              > Yahoo! Presentation Platform Engineering
              >
              >
              >
              > On Oct 2, 2006, at 12:04 PM, jfasaldarriaga wrote:
              >
              > > Well, Im doing that but because I'll ready have the dates (from the
              > > DB), but my question is, doing something like that, a button with an
              > > onClick property that select all the dates on the current month, it's
              > > that posible ?
              > >
              > > Thx for your answer.
              > >
              > > --- In ydn-javascript@yahoogroups.com, Eric Miraglia <miraglia@>
              > > wrote:
              > > >
              > > > jfasaldarriaga,
              > > >
              > > > The easiest way to select all the dates of a month is to do so when
              > > > you create your calendar instance. Here is code that would create a
              > > > calendar with every date in October selected:
              > > >
              > > > <div id="calendar"></div>
              > > >
              > > > <script>
              > > > var myCal = new YAHOO.widget.Calendar("calendarEl",
              > > > "calendar","10/2006","10/1/2006-10/31/2006");
              > > > myCal.Options.MULTI_SELECT = true;
              > > > myCal.render();
              > > > </script>
              > > >
              > > > Once the Calendar instance has been created, you can select dates
              > > > using the select method, which takes as its argument a date
              > > string or
              > > > one or more Date objects. See the documentation for this method for
              > > > more on how to use it. Note that you need to render after using
              > > select.
              > > >
              > > > Regards,
              > > > Eric
              > > >
              > > >
              > > > ______________________________________________
              > > > Eric Miraglia
              > > > Yahoo! Presentation Platform Engineering
              > > >
              > > >
              > > >
              > > > On Sep 29, 2006, at 12:47 PM, jfasaldarriaga wrote:
              > > >
              > > > > Can I made a function to select all days of a month ? I mean
              > > without
              > > > > any manipulation of the calendar.js ?
              > > > >
              > > > >
              > > > >
              > > >
              > >
              > >
              > >
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.