JQuery multi marquee multi level linkage plug in

  • 2020-03-30 02:49:39
  • OfStack

JQuery implementation of the multi-marquee linkage plug-in
 
//Use: $(_event_src_).autoselect (_reload_, reload_url);
//The foreground is transmitted by the get method. Select> Tag attributes "name" and check <Option> Attribute "value"
//The data is transferred in json format in the background
//Format: {value:<Option> Property "value", text:<Option> Display text}
(function($) { 
$.fn.extend({ 
autoSelect: function(dest, url) { 
return this.each(function() { 
$.SelectChange($(this), $(dest), url); 
}); 
}, 
}); 

//Reset check box
$.SelectReset = function(target) { 
if (target != null) { 
$.SelectReset(target.data("nextSelect")); 
target.empty(); 
target.append(target.data("defaultOpt")); 
} 
}; 

//Load check box
$.SelectLoad = function(target, data) { 
$.each(data, function(index, content) { 
var option = $("<option></option>") 
.attr("value", content.value).text(content.text); 
target.append(option); 
}); 
}; 

//Bind change event
$.SelectChange = function(target, dest, url) { 
//Binding linkage chain
target.data("nextSelect", dest); 

//Record the first option
if (target.data("defaultOpt") == null) 
target.data("defaultOpt", target.children().first()); 
dest.data("defaultOpt", dest.children().first()); 

$(document).ready(function() { 
target.change(function(event) { 
var _target = event.target || window.event.srcElement; 
if (_target.value != target.data("defaultOpt").attr("value")) { 
$.getJSON(url, { 
"name": _target.name, 
"value": _target.value 
}, function(data, status) { 
if (status == "success") { 
$.SelectReset(target.data("nextSelect")); 
$.SelectLoad(target.data("nextSelect"), data); 
} 
}); //The data is transmitted in json format behind the scenes
} else { 
$.SelectReset(target.data("nextSelect")); 
} 
}); 
}); 
}; 
})(jQuery); 

Related articles: