How are you using Materialize
, just do it as follows:
$('#btnDelteYes').click(function () {
var id = $('#myModalDelete').data('id');
$.post('estrutura/excluirarquivo.php',{acao:'delete',id:id},function(r) {
var m = jQuery.parseJSON(r);
if (m.success) {
toastr["success"](m.msg);
$('#myModalDelete').modal('hide');
/* Executa o evento de clique na "tab" */
$("[href=\"#panel80\"]").click();
} else {
toastr["error"](m.msg);
$('#myModalDelete').modal('hide');
}
hideMessage();
});
});
Example:
$("#btn").click( function() {
$("[href=\"#panel80\"]").click();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
<div class="row">
<div class="col s12">
<ul class="tabs">
<li class="tab col s3"><a class="active" href="#test1">Test 1</a></li>
<li class="tab col s3"><a href="#panel80">Test 2</a></li>
<li class="tab col s3 disabled"><a href="#test3">Disabled Tab</a></li>
<li class="tab col s3"><a href="#test4">Test 4</a></li>
</ul>
</div>
<div id="test1" class="col s12">Test 1</div>
<div id="panel80" class="col s12">Test 2</div>
<div id="test3" class="col s12">Test 3</div>
<div id="test4" class="col s12">Test 4</div>
</div>
<button id="btn" class="button">Acessar Tab 2</button>
If you want to refresh the page, just run: window.location.reload()
Example:
$('#btnDelteYes').click(function () {
var id = $('#myModalDelete').data('id');
$.post('estrutura/excluirarquivo.php',{acao:'delete',id:id},function(r) {
var m = jQuery.parseJSON(r);
if (m.success) {
toastr["success"](m.msg);
$('#myModalDelete').modal('hide');
/* Recarrega a página */
window.location.reload()
} else {
toastr["error"](m.msg);
$('#myModalDelete').modal('hide');
}
hideMessage();
});
});
To do the simplest way of all put in the Success block the command $("#Idbotao"). Trigger(); You can see more about Trigger http://api.jquery.com/trigger/ and implement a custom event or just "click" $("#Idbotao"). Trigger("click");
– Pedro Muniz