OrderEditShippingAddressHandler = Class.create(); OrderEditShippingAddressHandler.prototype = Object.extend(new CommonHandler(), { //---------------------------------- initialize: function(countryElementId, regionContainerElementId, regionElementName) { this.countryElementId = countryElementId; this.regionContainerElementId = regionContainerElementId; this.regionElementName = regionElementName; }, //---------------------------------- countryCodeChange: function() { var self = OrderEditShippingAddressHandlerObj; new Ajax.Request( M2ePro.url.getCountryRegions, { method: 'get', asynchronous: true, parameters: { country: $(self.countryElementId).value }, onSuccess: function(transport) { self.renderRegions(transport.responseText.evalJSON(true)); } }); }, renderRegions: function(data) { var self = OrderEditShippingAddressHandlerObj, regionContainer = $(self.regionContainerElementId), html = ''; if (data.length == 0) { html = '' .replace(/%name%/, self.regionElementName) .replace(/%value%/, M2ePro.formData.region); } else { html += ''; } regionContainer.innerHTML = html; } //---------------------------------- });