diff --git a/src/brazilian_zipcode/static/getAddressInfo.js b/src/brazilian_zipcode/static/getAddressInfo.js index cfb0a80..f0f357b 100644 --- a/src/brazilian_zipcode/static/getAddressInfo.js +++ b/src/brazilian_zipcode/static/getAddressInfo.js @@ -23,22 +23,28 @@ function createReadOnlyInput(label, value) { const parentDiv = input.parentNode.parentNode.parentNode; removeReadOnlyInput(label); - const div = document.createElement("div"); - div.classList.add("form-row"); - div.setAttribute("meta-id", label) + const externalDiv = document.createElement("div"); + externalDiv.classList.add("form-row"); + externalDiv.setAttribute("meta-id", label) + + + const innerDiv = document.createElement("div"); + innerDiv.classList.add("input-field"); const valueDiv = document.createElement("div"); - const labelElement = document.createElement("label"); + const labelDiv = document.createElement("div"); + labelDiv.classList.add("readonly-label"); + const labelElement = document.createElement("label"); labelElement.innerText = label + ":"; - labelElement.classList.add("required"); - div.appendChild(labelElement); + innerDiv.appendChild(labelElement); valueDiv.classList.add("readonly"); valueDiv.innerText = value; - div.appendChild(valueDiv); + innerDiv.appendChild(valueDiv); - parentDiv.appendChild(div); + externalDiv.appendChild(innerDiv) + parentDiv.appendChild(externalDiv); } function getAddressInfo(zipcode) { @@ -83,6 +89,6 @@ function handleOnFocusOutEvent(event) { $(document).ready(function () { - const input = document.querySelector(zipcodeMetaId); + const input = document.querySelector(zipcodeSelector); input.addEventListener("focusout", handleOnFocusOutEvent) }); \ No newline at end of file diff --git a/src/brazilian_zipcode/widgets.py b/src/brazilian_zipcode/widgets.py index f98433c..5d79572 100644 --- a/src/brazilian_zipcode/widgets.py +++ b/src/brazilian_zipcode/widgets.py @@ -3,9 +3,9 @@ class AutoBrazilianZipCodeInput(widgets.TextInput): - def render(self, name, value, **attrs): + def render(self, name, value, attrs, renderer): attrs["meta_id"] = "meta_zipcode_info" - return super().render(name, value, attrs) + return super().render(name, value, attrs, renderer) class Media: js = ("getAddressInfo.js",)