internet explorer 9 - JQuery not working in IE 9.0.8, but works with dev tools open -
the following works in browsers except ie 9.0.8. loads survey form within div ajax request.
$('.tab-content').on('click', '.show_survey_form', function(e) { e.preventdefault() target = $(this).attr("data-target") my_href = $(this).attr("href") console.log("load: " + target + " target: " + my_href) // load: #survey_response_form_33 target: /surveys/33/survey_responses/edit_multiple // don't make request unless form opening. if ($(this).hasclass('collapsed')) { console.log("making request!") //$(target).load(my_href) $(this).html(closesurveyform) // changes language on button } else { $(this).html(respondtosurvey) // changes language on button } }
the .load commented out during debugging. ie seems have problem using .hasclass in context. it's used elsewhere no issue.
the odd part moment open dev tools window, starts working. consistently doesn't work before then, , consistently works after hitting f12.
other issues have said hasclass method doesn't work when class contains \r char isn't case here. i'm using jquery 1.8.3.
update: changing href "#" , writing url data-load had no effect. still works in browsers except ie 9.0.8.
this has nothing jquery or hasclass()
. entirely down use of console.log()
.
it important know ie not define console
object until f12 dev tools window has been opened.
this means before open it, console
calls throwing javascript "object undefined" errors. make appear code around isn't working, it's fact console object missing.
you may have similar effects in other older browsers, current browser versions not -- define console
object immediately, regardless of whether dev tools open or not. ie exception.
you can around either (a) not using console
unless debugging , have dev tools open, or (b) adding if(console)
check console
calls. prevent error.
further information here: why javascript work after opening developer tools in ie once?
Comments
Post a Comment