Passing argument to .on event

2415
0
04-17-2015 05:16 AM
CharlesGant
New Contributor III

I have a function that accepts a variable as an argument, within that function I have a .on event.  On the first run it works just fine, however when I call the function after the initial load with a different argument, it fails just before the .on event.  I tried using the data method in the .on documentation but that didn't work either.  Below is the code.  I'm passing the argument from a JQuery slider.  I know the new value is being passed to the function via my multitude of console print statements.  Anyone know what is going on?

    var csv360min;

    var csv360mintextLayer;

    function csv360minfunc(VALUE) {

    console.log("HERE");

    console.log(VALUE);

    csv360min = new CSVLayer("symGSPHydroViewer/data/360query.csv",{id:"csv360min",refreshInterval: .50});

    csv360mintextLayer = new GraphicsLayer({refreshInterval: .50}); 

    console.log(VALUE);

    csv360min.on("update-end", function(results){

        console.log(VALUE);

        csv360mintextLayer.clear();

        console.log("360HERE");

        arrayUtils.forEach(results.target.graphics, function(feature, index){

            var lid =  feature.attributes.lid;

            var name =  feature.attributes.name;

            var value = feature.attributes.value;

            if (value >= VALUE) {

            var ffg = feature.attributes.ffg;

            var ratio = feature.attributes.ratio;

            var validtime = feature.attributes.obstime;

            var attr = {"Location ID":lid.bold(),"Location Name":name,"Obs Value":value.bold(),"6 Hour FFG":ffg,"Ratio of FFG":ratio.bold() + "%","Obs             Valid Time":validtime};                                                                              

            var geom = feature.geometry;

            var displayText = feature.attributes.value;

            var displayTextRatio = feature.attributes.ratio;

            returnedvalues = ratioColor(displayTextRatio);

            coloralt = returnedvalues[0];

            FontSize = returnedvalues[1];

            HaloColor = returnedvalues[2];

            var Halofont = new Font(FontSize,Font.STYLE_NORMAL, Font.VARIANT_NORMAL,Font.WEIGHT_BOLDER,"Helvetica");

            var textSymbolSouth = new TextSymbol(displayText,Halofont,new Color(HaloColor));

            textSymbolSouth.setOffset(0,-1);

            var textSymbolNorth = new TextSymbol(displayText,Halofont,new Color(HaloColor));

            textSymbolNorth.setOffset(0,1);

            var textSymbolEast = new TextSymbol(displayText,Halofont,new Color(HaloColor));

            textSymbolEast.setOffset(1,0);

            var textSymbolWest = new TextSymbol(displayText,Halofont,new Color(HaloColor));

            textSymbolWest.setOffset(-1,0);

            csv360mintextLayer.add(new Graphic(geom, textSymbolSouth, attr));

            csv360mintextLayer.add(new Graphic(geom, textSymbolNorth, attr));

            csv360mintextLayer.add(new Graphic(geom, textSymbolEast, attr));

            csv360mintextLayer.add(new Graphic(geom, textSymbolWest, attr));

            var font = new Font(FontSize,Font.STYLE_NORMAL, Font.VARIANT_NORMAL,Font.WEIGHT_BOLD,"Helvetica");

            var textSymbol = new TextSymbol(displayText,font,new Color(coloralt));                       

            csv360mintextLayer.add(new Graphic(geom, textSymbol, attr));

            }

            });                       

        var infoTemplate = new InfoTemplate("Attributes", "${*}");       

        csv360mintextLayer.setInfoTemplate(infoTemplate);

    });                               

    var blank = new Color([0, 0, 0, 0]); // hex is #ff4500

    var marker = new SimpleMarkerSymbol("solid", 0, null, blank);

    var renderer = new SimpleRenderer(marker);

    csv360min.setRenderer(renderer);

    map.addLayer(csv360min);

    map.addLayer(csv360mintextLayer);   

    csv360min.hide();

    csv360mintextLayer.hide();   

    }

   

    csv360minfunc(0);

$(function() {

    $( "#slider" ).slider({

    value:0,

    min: 0,

    max: 1,

    step: 0.25,

    slide: function( event, ui ) {

    //console.log("FILTERVALUE: " + ui.value);

    var FILTERVALUE = ui.value;

    if (FILTERVALUE == 0.00){LABEL = 'Showing Precip > 0.00"';}

    if (FILTERVALUE == 0.25){LABEL = 'Showing Precip > 0.25"';}

    if (FILTERVALUE == 0.50){LABEL = 'Showing Precip > 0.50"';}

    if (FILTERVALUE == 0.75){LABEL = 'Showing Precip > 0.75"';}

    if (FILTERVALUE == 1.00){LABEL = 'Showing Precip > 1.00"';}

    //console.log("LABEL: " + LABEL);

    $("#label").html(LABEL);

    csv360minfunc(FILTERVALUE);

        }

    });

}); 

0 Kudos
0 Replies