0
I have an Ajax function that when added, inserts/ updates a page. php
$("#recarrega-adt").click(function(event) {
$.ajax({
url : 'classes/consulta-aditivo.php',
success : function(txt){
$('#view-full-adt').load('classes/consulta-aditivo.php');
},
error: function(result) {
alert("Erro");
/*sweet alert*/
}
});
});
The problem is that when this action is performed the other JS/Jquery functions stop working, as this code was inserted "after" the rest was executed.
How should I solve this problem? I found the method live()
and on()
, however both did not take effect... The only way I found was to leave the method on the same page that is called but would not like to do this =/
Thank you in advance.
$(document).ready(function(){
$(".option-aditivo h3").on("click",function(){
alert('teste');
var id = this.id;
var frase = this.title;
$("<span class='frase-aditivo mover' id='adt"+id+"-enable'>"+frase+"</span>").appendTo("#papel");
$(this).removeAttr('id')
$(this).attr('id',id+"-plus");
Draggable.create("[id*=adt]");
});
});
the code is within $(Document). ready(Function(){//seuajax}) ?
– LucaoA
you can show how the other functions are being called?
– Tafarel_Brayan
@Lucaoa Are Yes...
– user48796
@Tafarel_brayan Hello, Follow function code to be executed.
– user48796
vc can do as follows instead: $(". option-additive H3"). on("click", Function(){} do this: $(Document). on("click", ". option-additive H3", Function(){}...
– Tafarel_Brayan
@user48796 already checked if the console is not showing any error ? Because depending on the error, it is very likely that "lock" your javascript
– LucaoA