Reputation: 13
I got a problem with a button behaviour:
it's a inside a jQuery Tab, inside a jQuery Dialog, inside a .
When the button is clicked, instead of executing a function, its validate the form wich refresh the page and insert a new blank entry in my database.
I just want it to append a new in the one i tell it.
the html:
<td colspan="2" align="center">
<button id="newgroup-anacuad">Añadir una fecha de fotos</button><br />
<div id="newgroup-divfotos"></div>
</td>
the javascript:
$('#diagnewgroup').dialog({
...
open:function(){
$("#newgroup-anacuad").button();
$("#newgroup-anacuad").bind("onclick",function(){
var txt='blabla';
$("#newgroup-divfotos").append(txt);
});
...
}
buttons:
{
'Validar':function()
{
var valid=true;
var errores='';
if(valid==true)
{
$('#formnewgroup').submit();
}
else
{
alert(errores);
}
},
'Cancelar':function()
{
$(this).dialog('close');
$('#diagnewgroup').remove();
}
}});
Does anyone has encountered this before?
Upvotes: 1
Views: 375
Reputation: 73
Try to replace
<button id="newgroup-anacuad">Añadir una fecha de fotos</button>
with
<input type="button" id="newgroup-anacuad" value="Añadir una fecha de fotos"/>
In some browsers
<button>
is usually acts as
<input type="submit">
Additionally you should replace "onclick" with "click" in
$("#newgroup-anacuad").bind("onclick",function(){
var txt='blabla';
$("#newgroup-divfotos").append(txt);
});
or you can rewrite in to something like:
$("#newgroup-anacuad").click(function(){
var txt='blabla';
$("#newgroup-divfotos").append(txt);
});
Upvotes: 2