0

I have a

<div id="config-wrapper">
    <button id="submit-success">Continue</button>
</div>

In the .js that I load with the page I have the following in the document.ready:

$("#submit-success").live("click", function(e) {
    e.preventDefault();
    $.get("../html/configurador/houseDetails.html", function(data) {
        $('#config-wrapper').html(data);      
        reloadTexts();
    });
});

My reloadTexts() function traverses all DOM elements with class="trad" and appends the translation according to what's found in a lang.es.json file It looks like this:

function reloadTexts(){ 

    alert("I'm reloading...");  //It popups, meaning function gets called

    $(".trad").each(function (i) {      
        var key = jQuery(this).attr("key");
        var value = _(key)
        jQuery(this).html(value);
    }); 
}

So, the callback method (reloadTexts()) definitely gets invoked but it seems that .each function fails to traverse the DOM that it has recieved...

Of, course this problem exists in IE (ver 8) and not in Chrome and Firefox!

Any ideas what might be causing this problem in IE?

Thanks in advance...

1
  • 2
    There's a semicolon missing after the value var declaration, and you call a _() function which is not specified. Do you get any error in console?
    – mamoo
    Feb 29, 2012 at 14:12

1 Answer 1

1

I didn't know where to write this so I will answer my own question... The problem in IE was that my html wasn't valid... I read about this problem somewhere else when I was trying to solve it, but looking at my code I saw that all tags were properly closed, nested etc.

It seems that I used < legend> < /legend> not wrapped into < form>< /form> and this was enough for IE to fail...

I find it strange there is no exception from jQuery framework saying it's not valid html or that there's some kind of problem with the content...

Anyway, in IE callbacks in load("resource.html",function(){ //callback code}) or $.get(...) functions will fail to traverse and update DOM if the html content is not valid. I wouldn't bet that that code needs to be 100% valid, but if it is you shouldn't have any problem... Hope this helps someone

1
  • So how did you fix it in the end? Did you wrap/fix the invalid html content before parsing the content? Nov 22, 2013 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.