A
A
alex_maldinsky2017-11-30 01:25:43
JavaScript
alex_maldinsky, 2017-11-30 01:25:43

How to make city default in KLADR?

Please tell me how to implement the following:
You need to implement a search by default city (the city is determined using ip) and is substituted in the input, and the kladr already works only with the street (you need to search in this city) and the
house

var city = $container_address.find('#input-city'),
 street = $container_address.find('#input-street')

                        city.kladr({
                            'type': $.kladr.type.city,
                            'verify': true
                        });

                        street.kladr({
                            'type': $.kladr.type.street,
                            'parentInput': city,
                            'verify': true
                        });

But it gives:
parentType must equal "city" or "street"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex_maldinsky, 2017-11-30
@alex_maldinsky

Solution:
Immediately initialize:

city.kladr({
                            'type': $.kladr.type.city,
                            'verify': true
                        });

Further:
$.kladr.api({
                            type: $.kladr.type.city,
                            name: $('#input-city').val()
                        }, function (obj) {
                            $('#input-city').kladr('controller').setValue(obj[0]);
                        });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question