Вопрос

I'm trying to do something right after an ajax call (data) has finished loading the data in my div:

$(data).find('a').appendTo('#DIV').bind(function(e){

$(this).prop('href', function(_, href){
    url = href.split('/');          
    return href.replace(url[2], 'someUrl');
})   

});

So after the appendTo Im doing the href split and replace. It doesnt work, meaning the data gets loaded but the binded function split/replace doesnt catch up. What else can I try?

Это было полезно?

Решение

no need to bind().. bind() is for events.. just use the prop() straight away..

try this

 $(data).find('a')
        .appendTo('#DIV')
        .prop('href', function(_, href){ 
                  url = href.split('/');
                  return href.replace(url[2], 'someUrl');
                  });
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top