Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5992291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:30:38+00:00 2026-05-22T23:30:38+00:00

I’m trying to use a yui plugin that pulls from a json file and

  • 0

I’m trying to use a yui plugin that pulls from a json file and populates a div on the page. Everything should be a go, however, since the plugin never gets to the render stage, the rest of it does not run. It is successfully loaded otherwise (if I stick an alert or console.log at the beginning of the event, it works fine).

Here’s the code:

YUI.add('events', function(Y) {

   var urlEvents = //"/cgi-bin/eventview-json/?cal=admissions/events&days=10";
                       "/admissions/events/events.json";

   //var eventContainer = $("#insert-events");
   /* EventList class constructor */
   var EventList = function(config) {
      EventList.superclass.constructor.apply(this, arguments);
   };

   /*
    * Required NAME static field, to identify the class and
    * used as an event prefix, to generate class names etc. (set to the
    * class name in camel case).
    */
   EventList.NAME = "EventList";

   /*
    * Required NS static field, to identify the property on the host which will,
    * be used to refer to the plugin instance ( e.g. host.feature.doSomething() )
    */
   EventList.NS = "EventList";

   /*
    * The attribute configuration for the plugin. This defines the core user facing state of the plugin
    */
   EventList.ATTRS = {};


   var convertYYYYMMDDtoJS = function(s) {

      var a, jsdate = null;

      try {

         a = /^(\d\d\d\d)(\d\d)(\d\d)$/.exec(s);

         if (a) {
            jsdate = new Date(a[1], a[2]-1, a[3]);
         }
      } catch (ex) {
         /* Nothing */
      }

      return jsdate;
   };


   var insertEvents = function(id, response, e) {
    alert('hello');
      var i, resp, events, event, html, jsdate, label, seenevent, yyyymmdd;
      var maxevents = 5, eventcount;

      try {
         resp = Y.JSON.parse(response.responseText);
         events = resp.results;

         html = "";
         seenevent = {};
         eventcount = 0;
         yyyymmdd = "";
         for (i = 0; i < events.length; i++) {
            event = events[i];
            if (seenevent[event.title]) {
               continue;
            }
            seenevent[event.title] = true;

            if (event.date !== yyyymmdd) {
               // This is the first event on this date.

               // If we've seen maxevents events, then bail before starting a new day.
               if (eventcount >= maxevents) {
                  break;
               }

               // Put out a new label for this day.
               jsdate = convertYYYYMMDDtoJS(event.date);
               label = Y.DataType.Date.format(jsdate, {format: "%b %e %a"});

               /*
                * The first empty div below, "<div class='clear'></div>" is only needed for IE 7.
                * IE 7 does not properly clear both left and right floats when "clear: both" is specified
                * if the element itself is floated.  The extra div clears the floats, but isn't floated
                * itself.  The extra div doesn't cause any grief in newer browsers, so I add it always.
                */
               html += "<div class='clear'></div><div class='event-datelabel'>" + label + "</div>\n";
               yyyymmdd = event.date;
            }

            html += "<div class='event-text'>" + event.html + "</div>\n";
                        eventcount++;
         }
         this.get('host').setContent(html + "<div id='events-footer'><a href='/calendar/'>all events</a></div>");


      } catch(ex) {
         console.log("Error", ex);
         this.get('host').setContent("Event list not available");
         return;
      }
   };


var insertEventList = function(yyyy, mm, dd) {

   var url = urlEvents;

   if (yyyy) {
      url += '&yyyy=' + yyyy;
   }
   if (mm) {
      url += '&mm=' + mm;
   }
   if (dd) {
      url += '&dd=' + dd;
   }

   Y.io(url, {on: {success: insertEvents}, context: this});

};

   /* EventList extends the base Plugin.Base class */
   Y.extend(EventList, Y.Plugin.Base, {
        render: function() {
        insertEventList.call(this);
    }

   });
   //console.log("assigning", EventList);
   Y.namespace("Plugin").EventList = EventList;

}, '1.0.0' ,{requires:['node', 'base', 'plugin', "json-parse", "datatype-date"]});

Here’s the excerpt from the code with the render bit:

Y.extend(EventList, Y.Plugin.Base, {
        render: function() {
        insertEventList.call(this);
    }

Admittedly, YUI3 confuses me, and I would prefer other libraries, but I don’t have a choice in this situation. There’s likely one thing that I’ve just completely looked over.

Thanks guys

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:30:38+00:00Added an answer on May 22, 2026 at 11:30 pm

    I’ve used YUI3 plugins before and they are a bit difficult to grasp, but I’ll try to help if I can. Once you’ve created the plugin, which, from what I can tell, you’ve already done so successfully, you plug it into an object somewhere else in your code:

    someObj.plug(Y.Plugin.EventList, cfg);

    After that, you can access the plugin’s methods from within the object’s plugin namespace. In your case you’d do this like so:

    someObj.EventList.render();

    Hopefully I’m understanding your question correctly and I hope that helps clear some stuff up for you. Good luck! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.