[jQuery] Re: click a button returned by ajax

2009-09-09 Thread Carlos Santos

function live was what I needed.
But now another question.
it's possible to make a POSTwith AJAX, via a button also created with
AJAX, and store the return in a CONTAINER that does not exist in the
DOM, but must exist when the POST is done?

I.E.

/*Action on a button that still exist in the DOM*/
$('#BtMoreDefeito').live(click, function(){
$.post(
'more_defeito.php',{
//NumDef: NumDef,
Str : $(#form-defeitos).serialize()
},
function(data){
//NumDef = new Number(NumDef + 1);

/*This ID will still exist in the DOM as well.*/

//$('#NumItem').val(NumDef);
var htmlStr = $('#result_defeitos').html();

/*This ID will still exist in the DOM as well.*/

$('#result_defeitos').html(data);
}
);
});


[jQuery] Re: click a button returned by ajax

2009-09-08 Thread MorningZ

There's no reason why this shouldn't work... remember you cannot wire
an event to something that isn't on the DOM unless you:

(1) use the .live() functionality of jQuery (http://docs.jquery.com/
Events/live#typefn)

or

(2) do it after it is in the DOM, which my code shows below

$.post(
'more_item.php',
{ NumItem: NumeroItem, Str : $(#form-itens).serialize() },
function(data){
NumeroItem = new Number(NumeroItem + 1);
 $('#NumItem').val(NumeroItem);
 var htmlStr = $('#resut_itens').html();
 $('#resut_itens').html(data);
 //Wire up anchor to do something
 $(#BtMoreDefeito).click(function() {
   // Do something
 });
}
);



[jQuery] Re: click a button returned by ajax

2009-09-08 Thread rupak mandal
Hi carlos

try to use
http://docs.jquery.com/Events/live

thanks
Rupak

On Tue, Sep 8, 2009 at 8:54 PM, Carlos Santos carloeasan...@gmail.comwrote:


 I have a button that do appear on my page through a post with jquery:

 $.post(
'more_item.php',{
NumItem: NumeroItem,
Str : $(#form-itens).serialize()
},
function(data){
NumeroItem = new Number(NumeroItem + 1);
$('#NumItem').val(NumeroItem);
var htmlStr = $('#resut_itens').html();
$('#resut_itens').html(data);
}
 );

 it returns me a clickable link:

a href=javascript:void(0); id=BtMoreDefeito Default / a

 I want to create a JQUERY that clicking this BtMoreDefeito execute a
 POST:

 $('#BtMoreDefeito').click(function(){
$.post(
'more_defeito.php',{
NumDef: NumDef,
Str :
 $(#form-defeitos).serialize()
},
function(data){
NumDef = new Number(NumDef + 1);
$('#NumItem').val(NumDef);
var htmlStr = $('#result_defeitos').html();
$('#result_defeitos').html(data);
}
);
 });

 but this has not worked. the latter showed that jquery is inserted in
 the index.
 the main page that calls the button.
 jquery in a home can act on an ID loaded from another file with ajax?