Chain execution with Jquery

Asked

Viewed 84 times

0

I have a link that when clicked generates a modal, in this link contains an address that contains an id that is generated dynamically to each new registration the link of the page and the same of the link that changes and that the address of the link contains the id at the end, the issue is that when user click on the link that opens the modal need the page address to be changed to the link address that is the same of the page what changes and only the id that is included at the end of the address

Example:

Url page http://www.exemplo.com + '?id=2' that only this must be included here ?id=2 at the end of the address because in modal I will pick up this id via $_GET in PHP and also it is necessary that when changing the address automatically click again on the link to open the final modal with the address already changed my function that is below already changing the address and running the automatic click but this doing disorderly: the desired implementation steps would be:

  • Step 1 user clicks on the link, url is changed to the link address
  • Step 2 Run the final click again

Jquery code that I did to perform this procedure prorem is not working as desired:

$(function() {
    $('.event').click(function() {
        // Pega o valor do link clicado
        var href1 = this.href;
        // alert(href1);
        // Sobrescreve o link atual com o novo link e redireciona para o novo link
        $(window.document.location).attr('href', href1);`
    });

    // Executa novamente o click do botão
    $(".event").trigger("click");
});
  • This question is duplicated that of yesterday that you deleted a little while ago. Don’t delete questions just to ask them again. What you can do is improve them or be more specific to make it easier to help.

  • Put html code only with javascript not to help you

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.