开发者

select value not changing after ajax call

I have written a piece of code to generate a chart by values generated by an ajax call.

The problem is, the select (years) is not c开发者_如何学JAVAhanging its value after the call is done loading. The weird thing is, i can see its value changing (if i alert its current value) but it simply won't change.

The code:

http://pastebin.com/RNfLmdWy

The $.load_x function is a custom loader but it behaves the same as a regular $.getJson call.


Found it! This part is responsible:

var option = $(this).attr('id').split('option_');
$('#'+option[1]).val(String($cur_val));
setTimeout(function(){$('#'+option[1]).val(String($cur_val))}, 1000);

I don't know what were you trying to do here, but basically, the option variable becomes a array ["", "years"], and in the next step you are setting $("#"+option[1]) value to $cur_val variable which is anything found in the #option_years input.

Soooo to wrap it up. To get rid of the "my select is not changing its value" issue in this case just get rid of those lines or at least let me know what you wanted to do there :)

EDIT: Here's the example that works for me: http://pastebin.com/sFRT3GJa (tested on FF and Chrome). As you can see it the source I use jQuery 1.6.1, jQuery UI 1.8.16 and jqPlot 1.0.0b2_r792. Other than that I've moved the callback function of $.load_x and named it handleJSON. Then I passed the JSON data you've pasted in your question to mock the successfull response of the $.load_x function.


Before you make get_port_graph call, give some time for select box to change the dropdown since its heavy call. It will work.

function year_chart(year)
{
    settTimeout(function(){
        var d = new Date();
        get_port_graph("Uitporteringen "+year,d.getMonth(), year,'outport', 'chart1', 'bar');   
    }, 100);       

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜