Hi,

1. appendTo() appends content: adds content after everything that
already exists. You can use empty() to remove the contents before
appending, that's the exact same result as replace().
2. replaceAll only works the first time because you are replacing the
<ol> element with a <div>, so on the second run there is no
'#fichaFilme ol' for the function to find.

That kilometric string concatenation will be a pain to debug, there
are cleaner ways to do it. I took the liberty to recode your example:
http://pastebin.com/m333376fa

Basically you have a model mark-up for a movie and you clone it for
each one you are displaying, so you don't need to recreate all the
html in a string.

abraço,
- ricardo

On Nov 25, 9:24 am, "Dipi Evil Danger" <[EMAIL PROTECTED]> wrote:
> I´m trying to make an dynamic page with XML values. When the visitor click
> on an item it replaces the content. But it is not doing his job. This is the
> code:
> $('a').click(function() {
> var key = $(this).attr('id').charAt(4);
> $('a').click(function() {
> var key = $(this).attr('id').charAt(4);
>      $.ajax({
>          type: "GET",
>          url: "../cms/xmlCinema.php?id=000"+key,
>          dataType: "xml",
>          success: function(xml) {
>
>              $(xml).find("filme").each(function(){
>                 var texto = " ";
>                 var album = " ";
>                  var texto = '<div class="moviesTitle">' +
> $(this).find('nome').text() + ' (<i>' + $(this).find('ano').text() +
> '</i>)</div><br>';
>                  texto = texto + '<div class="moviesPoster"><img
> id="poster'+key+'" name="poster'+key+'"
> src="../cinema/poster/000'+key+'.jpg" width="95"></div>';
>                  texto = texto + '<div class="moviesLabel">Nome
> original:</div> <div class="moviesData">&nbsp;' +
> $(this).find('nome_original').text() + '</div>';
>                  texto = texto + '<div class="moviesLabel">Estréia:</div>
> <div class="moviesData">&nbsp;' + $(this).find('data').text() + '</div>';
>                  texto = texto + '<div class="moviesLabel">Trilha:</div>
> <div class="moviesData">&nbsp;' + $(this).find('trilha').text() + '</div>';
>                  texto = texto + '<div class="moviesLabel">Gênero:</div>
> <div class="moviesData">&nbsp;' + $(this).find('genero').text() + '</div>';
>                  texto = texto + '<div class="moviesLabel">País de
> Origem:</div> <div class="moviesData">&nbsp;' +
> $(this).find('pais_de_origem').text() + '</div>';
>                  texto = texto + '<div class="moviesLabel">Site:</div> <div
> class="moviesData">&nbsp;<a href="' + $(this).find('site').text() + '"
> target="_blank">' + $(this).find('site').text() + '</a></div>';
>                  texto = texto + '<div class="moviesLabel">Duração:</div>
> <div class="moviesData">&nbsp;' + $(this).find('duracao').text() + '
> min.</div>';
>                  texto = texto + '<div class="moviesLabel">Direção:</div>
> <div class="moviesData">&nbsp;' + $(this).find('duracao').text() + '
> min.</div>';
>                  //Sinopse
>                  texto = texto + '<div class="moviesLabel">Sinopse:</div>
> <div class="moviesRelease">&nbsp;' + $(this).find('sinopse').text() +
> '</div>';
>                 $('<div></div>')
>                      .html(texto)
>                      .replaceAll('#fichaFilme ol');
>              }); //close each(
>          } //close sucess
>      }); //close $.ajax(
>     $("#fichaFilme").fadeIn(3000);}); //close click(
>
> If I use "appendTo" it adds content. If I use replaceAll it only works in
> the first time.
>
> Here is the page (working on 
> it):http://www.ncweb.com.br/PHP/index.php?mod=Cinema
>
> Thanks!
>
> --
> dipi evil danger
> "Gott weiß ich will kein Engel sein"http://meadiciona.com/dipi

Reply via email to