Doubt Javascript function generating Postback

Asked

Viewed 125 times

0

I have this function in my system, which clears the fields, and updates the grid:

 $('.window .close').click(function (e) {
    //cancela o comportamento padrão do link
    e.preventDefault();
    $('#mask, .window').hide();
    document.location.href = '';
    document.getElementById("<%= txtid_recebimento.ClientID %>").value = '';
    document.getElementById("<%= txtidReceita.ClientID %>").value = '';
    document.getElementById("<%= modalExercutar.InnerText %>").value = 'Cadastrar Contas a Receber';
    GridRecebimento();
});

This function is in the X (close) of the modal, but on my page there are several tabs, and when I click and execute the function, it generates postback on the page, and loses the tab selected. When I clear the fields, it does not generate the postback. How can I make so that this function does not generate the postback of the entire page? I have tried several ways I saw in the forum, but none was viable.

  • This is not a forum. Otherwise, if this click generates a post, then the code that generates the post should be in the function GridRecebimento. Could edit the question to add the code of this function?

  • I did not only research here Renan, I researched in several places. I did the test taking the Gridrecebimento and the Postback occurred in the same way. I guess the problem isn’t him, then.

  • Then maybe the excerpt e.preventDefault(); is not actually canceling the event. I know this works on some browsers, but not on others. Leave that line there, but add event.returnValue = false;

  • I added Renan, e.preventDefault(); Event.returnValue = false; I put it just below e.preventDefault(); But the same thing happens, the function occurs, but I didn’t want q to perform the page postback!

No answers

Browser other questions tagged

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