Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

337
Visualizações
How init modal window for multiple times (Geowidget) Inpost

I have a marketplace with a few vendors. In cart clients who adds products from few vendors have to select few points of parcel locker. My script is good for one vendor - one select point but not for few. When client click on first select points - can't select next point because modal window is inicialized already and return data to first point. What can I improve to make javascript work independently of several vendors?

<script src="https://geowidget.easypack24.net/js/sdk-for-javascript.js"></script>
<script type="text/javascript">
    window.easyPackAsyncInit = function () {
        easyPack.init({
            defaultLocale: 'pl',
            mapType: 'osm',
            searchType: 'osm',
            points: {
                types: ['parcel_locker', 'pop'],
                functions: ['parcel_collect']
            },
            map: {
                initialTypes: ['parcel_locker'],
            }
        });
    };
    function openModal(id_method) {
        easyPack.modalMap(function(point, modal) {
            $('input[name="parcel_locker_name_'+id_method+'"]').val(point.name);
            modal.closeModal();
            console.log(point);
        }, { width: 500, height: 600 });
    }
</script>

and php/html:

<p>Vendor 1</p>
 <div class="parcel_locker">
    <input type="hidden" class="custom-control-input" name="parcel_locker_name_1" id="parcel_locker_name_1" value="">
    <button id="button_select_parcel_locker_1" class="btn btn-lg btn-custom" onclick="openModal(1); return false;">Select parcel locker</button>
</div>
<p>Vendor 2</p>
 <div class="parcel_locker">
    <input type="hidden" class="custom-control-input" name="parcel_locker_name_2" id="parcel_locker_name_2" value="">
    <button id="button_select_parcel_locker_2" class="btn btn-lg btn-custom" onclick="openModal(2); return false;">Select parcel locker</button>
</div>
<p>Vendor (n)</p>
 <div class="parcel_locker">
    <input type="hidden" class="custom-control-input" name="parcel_locker_name_(n)" id="parcel_locker_name_(n)" value="">
    <button id="button_select_parcel_locker_n" class="btn btn-lg btn-custom" onclick="openModal(n); return false;">Select parcel locker</button>
</div>
about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

I come up with idea to pass id in easyPack.init (vendor id for example)

window.easyPack.init({
        defaultLocale: "pl",
        mapType: "osm",
        searchType: "osm",
        packageID: singlePackage.packageID,   < -----
        points: {
            types: ["parcel_locker"],
        },
        map: {
            initialTypes: ["parcel_locker"],
        },
    });

then in window.easyPack.modalMap you can check passed id with

modal.easyPackConfig.packageID

and with this id save chosen point to certain vendor

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda