JSFiddle - React, Tailwind, and code Playground
by Lloyd Atkinson
HTML
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
JavaScript
const configureUrls = () => {
window.variables.urls = {
addStockVehicle: '@Url.Action("AddStockVehicle", "StockVehicles")'
};
};
const configureHandlers = () => {
};
const update = (data) => {
$('#addStockVehicleModal').html(data);
$('#addStockVehicleModal').modal(options);
$('#addStockVehicleModal').modal('show');
};
const error = () => {
alert("Content load failed.");
};
const addStockVehicle = () => {
axios
.get(window.variables.urls.addStockVehicle)
.then(response => {
update(response.data);
})
.catch(error => {
error();
})
};
$(() => {
$("#addStockVehicle").click(function () {
const $buttonClicked = $(this);
const options = {
"backdrop": "static",
keyboard: true
};
$.ajax({
type: "GET",
url: window.variables.urls.addStockVehicle,
contentType: "application/json; charset=utf-8",
datatype: "json",
success(data) {
debugger;
$('#addStockVehicleModal').html(data);
$('#addStockVehicleModal').modal(options);
$('#addStockVehicleModal').modal('show');
},
error() {
alert("Content load failed.");
}
});
});
$("#closbtn").click(() => {
debugger;
$('#addStockVehicleModal').modal('hide');
});
});