sparkartgroup-archive / sparkart.js

Easily interact with Sparkart's APIs via Javascript.
1 stars 0 forks source link

Events preprocessor error #25

Closed pushred closed 11 years ago

pushred commented 11 years ago

Getting this error on Fight Club when rendering the Event widget:

Uncaught TypeError: Cannot read property 'date' of undefined 3829.js:155
fanclub.preprocessors.event 3829.js:155
(anonymous function) 3829.js:423
jQuery.extend.each 3553.js:611
jQuery.fn.jQuery.each 3553.js:241
(anonymous function) 3829.js:422
(anonymous function) 3829.js:469
fire 3553.js:974
self.fireWith 3553.js:1082
done 3553.js:7788
callback 3553.js:8500

Here's the Events JSON in this instance:

{
    "status": "ok",
    "events": [{
        "id": 1,
        "title": "TUF 16",
        "date": "2012-12-15T00:00:00-0800",
        "start": null,
        "description": "",
        "timezone": "America/Los_Angeles",
        "doors_open": null,
        "venue": {
            "name": "The Joint at the Hard Rock Hotel",
            "address": "4455 Paradise Road",
            "city": "Las Vegas",
            "state": "NV",
            "postalcode": "89109",
            "country": "US",
            "lat": "36.1715",
            "lon": "-115.139"
        },
        "links": []
    }, {
        "id": 3,
        "title": "UFC 155 Live on PPV",
        "date": "2012-12-29T00:00:00-0800",
        "start": null,
        "description": "",
        "timezone": "America/Los_Angeles",
        "doors_open": null,
        "venue": {
            "name": "MGM Grand Garden Arena",
            "address": "3799 Las Vegas Boulevard South",
            "city": "Las Vegas",
            "state": "NV",
            "postalcode": "89109",
            "country": "US",
            "lat": "36.1",
            "lon": "-115.17"
        },
        "links": []
    }, {
        "id": 4,
        "title": "UFC ON FX",
        "date": "2013-01-20T00:00:00-0200",
        "start": "2013-01-20T00:00:00-0200",
        "description": "",
        "timezone": "America/Sao_Paulo",
        "doors_open": null,
        "venue": {
            "name": "Ginasio do Ibirapuera",
            "address": "",
            "city": "Sao Paulo",
            "state": "Sao Paulo",
            "postalcode": "04801-890",
            "country": "Brazil",
            "lat": "-23.58",
            "lon": "-46.66"
        },
        "links": []
    }, {
        "id": 6,
        "title": "UFC 156 Live on PPV",
        "date": "2013-02-02T00:00:00-0800",
        "start": null,
        "description": "",
        "timezone": "America/Los_Angeles",
        "doors_open": null,
        "venue": {
            "name": "Mandalay Bay Events Center",
            "address": "3950 Las Vegas Blvd. South",
            "city": "Las Vegas",
            "state": "NV",
            "postalcode": "89119",
            "country": "US",
            "lat": "36.092",
            "lon": "-115.174"
        },
        "links": []
    }, {
        "id": 5,
        "title": "UFC on FUEL TV",
        "date": "2013-02-16T00:00:00+0000",
        "start": null,
        "description": "",
        "timezone": "Europe/London",
        "doors_open": null,
        "venue": {
            "name": "Wembley Arena",
            "address": "Arena Square",
            "city": "London",
            "state": "London",
            "postalcode": "HA9 0DH",
            "country": "UK",
            "lat": "51.5223",
            "lon": "-0.12337"
        },
        "links": []
    }, {
        "id": 8,
        "title": "Rousey vs. Carmouche",
        "date": "2013-02-23T00:00:00-0800",
        "start": null,
        "description": "",
        "timezone": "America/Los_Angeles",
        "doors_open": null,
        "venue": {
            "name": "Honda Center",
            "address": "2695 East Katella Avenue",
            "city": "Anaheim",
            "state": "CA",
            "postalcode": "92806",
            "country": "US",
            "lat": "33.8064",
            "lon": "-117.877"
        },
        "links": []
    }]
}
Fauntleroy commented 11 years ago

If you specify an event widget without specifying the data-id, you'll run into this problem. There is presently no special error handling for this circumstance. In the future we may want to consider showing something like "event not found" in the widget whenever this happens.