0

I'm trying to add a function to raphael that draws a calender with no success.

Here is my code:

Raphael.fn.calenderView = function () {

};

$(function () {
    var paper = Raphael('body');
    paper.calenderView();
});

The error that I am getting is that paper has no method calenderView. There is probably something blatantly wrong and maybe I'm just to tired to see it

Wryte
  • 885
  • 2
  • 10
  • 23

1 Answers1

0

You could do it like this:

$(function () {
    Raphael.fn.calenderView = function () {alert("calendar");};
    var paper = new Raphael(0,0,200,200);
    paper.calenderView();
});​

See example fiddle http://jsfiddle.net/58yqW/

Neil
  • 7,861
  • 4
  • 53
  • 74
  • this does work, but could someone explain to my why the function has to be made inside the document ready function – Wryte Sep 24 '12 at 14:28
  • The function just has to be assigned AFTER Raphael is loaded. It shouldn't have to wait until DOM ready. – jfriend00 Sep 24 '12 at 15:00
  • @jfriend00 is correct, my example uses dom ready to keep with your example code, its your choice how you implement it, I've merely shown you one way that DOES WORK! – Neil Sep 24 '12 at 15:36