Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call inner function of jQuery-wrapper $(function() { }?

I've got a function changeGraph() inside the jQuery-wrapper which I need to call somehow from outside it. I need to access the function setData from the jQuery based graph-library Flot.

The source is looking like this:

function changeGraph(){
    // I need to access $.plot.setData somehow
};  

var d2 = [[0, 0], [20, 300000]];

$(function () {              
    $.plot($("#placeholder"), 
    [{color: "#000000", data: d2}],
    {

    series: {
        lines: { show: true, fill:true, fillColor: {colors: [ "#d1ddea","#8e959d"]}},
        points: { show: false }
          }
       }
    );


});

How can I accomplish this?

like image 440
Hedge Avatar asked Dec 17 '22 12:12

Hedge


1 Answers

var changeGraph;

$(function () {

    changeGraph = function () {
        // Need to access $.plot($("#placeholder") here
    };

});

changeGraph(); // call this when document is ready at least
like image 101
Karolis Avatar answered Dec 24 '22 15:12

Karolis