Llamar a jQuery después del método con replaceWith

Tengo este bloque de código:

$('#mainContent').replaceWith(ucmResponse).after(function(){alert('jym')});

But I am not getting the alert. I wanted to hide the '#mainContent' después de la replaceWith se completa el método.

preguntado el 31 de julio de 12 a las 13:07

3 Respuestas

$(ucmResponse).replaceAll('#mainContent').hide();

Respondido 31 Jul 12, 13:07

$('#mainContent').replaceWith(ucmResponse).hide();

Respondido 31 Jul 12, 13:07

hmmm... replaceWith doesn`t has callback.. that is ucmResponse ? - voodoo417

It wont work - because the #mainContent div has been replaced ! so there is nothing to hide - Casa del pastor

or if try ... $('#mainContent').empty(); $('#mainContent').append(ucmResponse).hide(); - voodoo417

ucmResponse it is a function or jQuery object ? in second case you can just ucmResponse.hide() - zb '

It is a jQuery object: $.ucm.executeService(submitData,function(ucmResponse) {$('#mainContent').replaceWith(ucmResponse);}}); - Tapas Bosé

Method after is not supposed to be event:

function(index)A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set.

just place alert in each() method:

$('#mainContent').replaceWith(ucmResponse).each(function(){alert('jym')});

or just as next command:

$('#mainContent').replaceWith(ucmResponse);
alert('jym');

Respondido 31 Jul 12, 13:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.