If I have a page with three cascading dropdownlists, is that an example of controlling the state of a web application (assume it is part of a larger application)?
I want to make sure I understand state management and the need for a system like Vuex and Redux and having the store pattern, one singleton to run it all through, reducing complexity, and so on I know the React and Redux folks said it'd be like wearing glasses, you know if you need them, and in addition, this could be done quite easily with no framework.
But, in general, is the usage of a cascading dropdownlist an example, albeit incredibly simple, of keeping track of "state"?
For reference of a dropdownlist see, How to populate a cascading Dropdown with JQuery
jQuery(function($) {
var locations = {
'Germany': ['Duesseldorf', 'Leinfelden-Echterdingen', 'Eschborn'],
'Spain': ['Barcelona'],
'Hungary': ['Pecs'],
'USA': ['Downers Grove'],
'Mexico': ['Puebla'],
'South Africa': ['Midrand'],
'China': ['Beijing'],
'Russia': ['St. Petersburg'],
}
var $locations = $('#location');
$('#country').change(function () {
var country = $(this).val(), lcns = locations[country] || [];
var html = $.map(lcns, function(lcn){
return '<option value="' + lcn + '">' + lcn + '</option>'
}).join('');
$locations.html(html)
});
});
Aucun commentaire:
Enregistrer un commentaire