Unfortunately I can't create a jsFiddle because this requires a valid URL returning HTML but the point is I'm using an input mask , which stops working after execution of $.load()
I think it's me just not understanding this function very well.
script:
(function () {
isa.uk.HpiLookup = (function () {
function HpiLookup() { }
HpiLookup.prototype.setupEventHandlers = function () {
return $('#hpiLookupContainer').on("click", "#vehicleRegistrationSearchButton", this.onVehicleRegistrationSearchButton);
};
HpiLookup.prototype.setupInputMasks = function () {
$('#VehicleRegistrationNumber').inputmask("#######", { "placeholder": "" });
};
HpiLookup.prototype.onVehicleRegistrationSearchButton = function (event) {
event.preventDefault();
return $('#hpiLookupContainer').load(
GetVehicleByRegistrationNumberUrl,
{
VehicleRegistrationNumber: $('#VehicleRegistrationNumber').val()
},
this.setupInputMasks);
};
return HpiLookup;
})();
}).call(this);
Index.cshtml:
<div id="hpiLookupContainer">
<input id="VehicleRegistrationNumber" type="text">
<button id="vehicleRegistrationSearchButton" type="button">Search</button>
</div>
<script type="text/javascript">
var GetVehicleByRegistrationNumberUrl = '@Url.Action("GetVehicleByRegistrationNumber", "Vehicle")';
var hpiLookup = new isa.uk.HpiLookup();
hpiLookup.setupEventHandlers();
hpiLookup.setupInputMasks();
</script>
I've tried to make $.load() callback the setupInputMasks
this way but it won't. How can I re-apply event bindings after jQuery.load()
?