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

Re: YUI Loader constructor problem

Expand Messages
  • mikeni1225
    ... this can t be the best solution...
    Message 1 of 8 , Jan 4, 2008
      --- In ydn-javascript@yahoogroups.com, Alan Pinstein <apinstein@...>
      wrote:
      >
      > Here's what you have to do...
      >
      > <body class="yui-skin-sam">
      > <script type="text/javascript"
      > src="../build/yuiloader/yuiloader-beta.js"></script>
      >
      > <div id="tabContainer"></div>
      >
      > <script type="text/javascript">
      >
      > loader = new YAHOO.util.YUILoader();
      > loader.require("tabview");
      > loader.base = "../build/";
      > loader.loadOptional = true;
      > loader.insert({ onSuccess: function() {
      > // set up your functions
      > YAHOO.example.tabviewinit = function( ){
      > var tabView = new YAHOO.widget.TabView( { id: 'generatedTabs' } );
      >
      > tabView.addTab( new YAHOO.widget.Tab({
      > label: 'lorem',
      > content: '<p>Lorem ipsum dolor sit amet...</p>',
      > active: true
      > }));
      >
      > tabView.addTab( new YAHOO.widget.Tab({
      > label: 'ipsum',
      > content: '<p>Lorem ipsum dolor sit amet...</p>',
      > }));
      >
      > tabView.addTab( new YAHOO.widget.Tab({
      > label: 'dolor',
      > content: '<p>Lorem ipsum dolor sit amet...</p>',
      > }));
      > tabView.appendTo('tabContainer');
      > };} });
      >
      > // Call doInitTabViewWhenAvailable() when you want your tabview set
      > up. It might not run IMMEDIATELY, because the tab stuff might not be
      > loaded yet. But it will run as early as it possibly can (within 500
      > ms which of course is tuneable).
      > // I think that this syntax is correct; I haven't done tons with
      > closure so you may have to explicitly pass in myTimer but I think
      > this is correct.
      > function doInitTabViewWhenAvailable() {
      > var myTimer = window.setInterval(500, function() {
      > if (YAHOO && YAHOO.example &&
      > YAHOO.example.tabviewinit) {
      > YAHOO.example.tabviewinit();
      > window.clearInterval(myTimer);
      > }
      > });
      > }
      >
      > I am not sure why you want to delay setting up your tabview... if it
      > were me I'd just do a:
      >
      > YAHOO.util.Event.onDomReady(function() {
      > YAHOO.examples.tabviewinit();
      > });
      >
      > But this should work for you.
      >
      > You must understand that YUILoader make async calls, and thus
      > introduces race conditions. So it is important to understand how this
      > works to ensure bug-free code. AJAX has effectively brought the
      > complex task of writing thread-safe code to all of us via async XHR,
      > which is unfortunate because dealing with race conditions is tricky.
      >
      > Good luck...
      >
      > Alan
      >
      > On Dec 25, 2007, at 9:10 AM, kakar0to wrote:
      >
      > > I would be greatfull when you could rewrite my example the way you
      > > know it will going to work.
      > >
      > > I am still getting this 'YAHOO.widget.TabView is not a constructor'
      > > error.
      > >
      > > --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@> wrote:
      > > >
      > > > Nothing of what you ask is going to be loaded until the onSuccess
      > > callback
      > > > is called, that is the signal for you to know that everything has
      > > been
      > > > loaded. You don't need to call tabviewinit from within the onSuccess
      > > > function but you cannot call it before onSuccess has been called,
      > > meaning,
      > > > you can leave a flag somewhere signaling that everything is loaded,
      > > or you
      > > > can also check YAHOO.env.modules to see if what you have asked
      > > for is
      > > > already there.
      > > >
      > > > Satyam
      > > >
      > > > ----- Original Message -----
      > > > From: "kakar0to" <kakar0to@>
      > > > To: <ydn-javascript@yahoogroups.com>
      > > > Sent: Monday, December 24, 2007 12:48 PM
      > > > Subject: [ydn-javascript] YUI Loader constructor problem
      > > >
      > > >
      > > > >I am using YUI 2.3.1 with the YUI Loader module.
      > > > > So it was pretty simple to setup a config object and initiate the
      > > > > loader which was going to load all required files from the given
      > > source.
      > > > >
      > > > > When YUI 2.4.0 was released i was exited about the new changes and
      > > > > tryed to use them on my script but without any luck.
      > > > > My current problem is the onSuccess callback funtion insie the
      > > loader.
      > > > > It seems to insist on initiating the objects i am loading with
      > > the YUI
      > > > > Loader. I have tryed many example scripts without any luck to
      > > get them
      > > > > working the way they used to work.
      > > > >
      > > > > Here i an example i was working with.
      > > > >
      > > > >
      > > > > <body class="yui-skin-sam">
      > > > > <script type="text/javascript"
      > > > > src="../build/yuiloader/yuiloader-beta.js"></script>
      > > > >
      > > > > <div id="tabContainer"></div>
      > > > >
      > > > > <script type="text/javascript">
      > > > >
      > > > > loader = new YAHOO.util.YUILoader();
      > > > > loader.require("tabview");
      > > > > loader.base = "../build/";
      > > > > loader.loadOptional = true;
      > > > > loader.insert({ onSuccess: function() {
      > > > > //YAHOO.example.tabviewinit(); //WHEN USEING THIS CALLBACK
      > > EVERYTHING
      > > > > IS FINE!!!
      > > > > }});
      > > > >
      > > > > YAHOO.example.tabviewinit = function( ){
      > > > > var tabView = new YAHOO.widget.TabView( { id: 'generatedTabs' } );
      > > > >
      > > > > tabView.addTab( new YAHOO.widget.Tab({
      > > > > label: 'lorem',
      > > > > content: '<p>Lorem ipsum dolor sit amet...</p>',
      > > > > active: true
      > > > > }));
      > > > >
      > > > > tabView.addTab( new YAHOO.widget.Tab({
      > > > > label: 'ipsum',
      > > > > content: '<p>Lorem ipsum dolor sit amet...</p>',
      > > > > }));
      > > > >
      > > > > tabView.addTab( new YAHOO.widget.Tab({
      > > > > label: 'dolor',
      > > > > content: '<p>Lorem ipsum dolor sit amet...</p>',
      > > > > }));
      > > > > tabView.appendTo('tabContainer');
      > > > > };
      > > > >
      > > > >
      > > > > YAHOO.example.tabviewinit(); //This is what i want to execute.
      > > > >
      > > > > </script>
      > > > > </body>
      > > > >
      > > > > My goal is to load all the sources i need and then initiate the
      > > object
      > > > > whenever it pleases me :) not relying on the OnSuccess.
      > > > >
      > > > > Please give me some help on this one.
      > > > >
      > > > >
      > > > >
      > > > >
      > > > > Yahoo! Groups Links
      > > > >
      > > > >
      > > > >
      > > > >
      > > > >
      > > > > --
      > > > > No virus found in this incoming message.
      > > > > Checked by AVG Free Edition.
      > > > > Version: 7.5.516 / Virus Database: 269.17.7/1194 - Release Date:
      > > > > 23/12/2007 17:27
      > > > >
      > > > >
      > > >
      > >
      > >
      > >
      >

      this can't be the best solution...
    Your message has been successfully submitted and would be delivered to recipients shortly.