我正在使用adminlte3主题为我的姜戈项目。在这个项目中,我有一个表单与ajax依赖下拉控件。在添加工厂表单中,此下拉列表(公司)将根据国家/地区的选择进行填充。但是当我使用adminlte3模板时,它不工作。请参阅github链接。https://github.com/shahidpharm/qtrack
有谁可以帮我?
谢谢
发布于 2021-01-04 18:11:30
我已经解决了我的问题。我的问题是我没有在add_plant.html文件的内容块中包含下面的代码。
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
$("#id_country").change(function () {
var url = $("#pForm").attr("data-url_root"); // get the url of the `load_cities` view
var countryId = $(this).val(); // get the selected country ID from the HTML input
console.log(countryId);
$.ajax({ // initialize an AJAX request
url: url, // set the url of the request ? localhost:8000/hr/ajax/load-cities/)
data: {
'country': countryId // add the country id to the GET parameters
},
success: function (data) { // `data` is the return of the `load_cities` view function
$("#id_company").html(data); // replace the contents of the city input with the data that came from the server
}
});
});
</script>
现在我的代码可以工作了。感觉很好。
https://stackoverflow.com/questions/65550291
复制相似问题