show("show") does not work on firefox

Asked

Viewed 106 times

0

show("show") is not working on firefox. This same code works on Chrome.

What would be wrong?

$('#conteudo').hide();

<?php if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { ?>
	$(document).ready(function(){ 
		event.preventDefault(); 
		$("#form").hide("slow"); 
		$("#conteudo").show("slow"); 
	});
<?php } ?>

$('#mostrar').click(function(event){
	event.preventDefault();
	$("#form").show("show");
	$("#conteudo").hide("show");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

<a class="btn btn-success" id="mostrar"><i class="fa fa-bar-chart-o"></i> Gerar outro</a>

<div class="form-actions clearfix" id="form">
<form action="relatorioGeralDetalhado.php" method="post" name="form1" id="form1" class="form-inline" role="form">
	<label class="inline">
		<input class="form-control" type="text" required name="date-range-picker" id="id-date-range-picker-1" placeholder="Selecione a data" data-date-format="dd-mm-yyyy" />
	</label>
	<button type="submit" id="button" name="button" class="btn btn-success btn-sm gerar"><i class="icon-save bigger-110"></i> Gerar</button>
	<input type="hidden" name="MM_insert" value="form1" />
</form>
</div>

<table class="table table-hover" id="conteudo">
tabela aqui.
</table>

What would that mistake be?

inserir a descrição da imagem aqui

3 answers

5

Your code has a reference error in:

$(document).ready(function(){ 
    event.preventDefault(); 
    $("#form").hide("slow"); 
    $("#conteudo").show("slow"); 
});

At this time, event is not defined.

Remove this line:

event.preventDefault();

In your click Handler, change from "show" to "slow":

$('#mostrar').click(function(event){
    event.preventDefault();
    $("#form").show("slow");
    $("#conteudo").hide("slow");
})
  • Buddy, rename it what name?

  • Remove the line event.preventDefault();, it is not used in ready.

  • @Sergiogarcia Why does Chrome work and firefox not ? does Chrome function ready has Event ?

  • The ready code generates error for me in Chrome as well (Uncaught TypeError: Cannot read property 'preventDefault' of undefined(…))

  • So much $("#form").show("slow"); how much $("#form").show("show"); work in both browsers.

1

$(document).ready(function(){ 
    event.preventDefault(); 
    $("#form").hide("slow"); 
    $("#conteudo").show("slow"); 
});

At this point you still haven’t set Event (and it doesn’t even make sense that Event.preventDefault in the ready of the body).

0

Hello, thank you all... You know that moment of distraction, you do things but don’t pay attention to what’s on the screen... kkkk

Correct, it was very simple.

1º) I had forgotten to put a else and put the $('#conteudo').hide();, within it.

2º) You did not need to use the event.preventDefault();, I don’t even know why I put him...

I thank you all for your help, if it hadn’t been for you, I wouldn’t have committed my mistake.

Grateful to all!

Browser other questions tagged

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