Reputation: 7737
I've been trying to get a modal working and it seems fine on all tested browsers, except for one problem on IE9. On page load, the modal does not work. If I then open the dev tools and close them again (or even just keep them open), it works fine. How can I even debug this issue?
Edit: Here's the link: http://dev.birddartmouth.co.uk
Here's my code.
HTML:
<a href="#" class="item" data-reveal-id="292">
<img src="http://dev.birddartmouth.co.uk/wp-content/uploads/2013/10/096.jpg" />
</a>
<div id="292" class="reveal-modal">
<a href="#" class="close-reveal-modal"><i class="close icon close-reveal-modal"></i></a>
<div class="header">
Bow tie neck silk overlay top/dress with sequin hem – cream, grey <p>£0</p>
</div>
<div class="content">
<img src="http://dev.birddartmouth.co.uk/wp-content/uploads/2013/10/096.jpg" />
</div>
</div>
JS:
$( "a.item" ).click(function( event ) {
event.preventDefault();
var elementClicked = "#" + $(this).attr("data-reveal-id");
console.log(elementClicked);
$(elementClicked).foundation('reveal', 'open');
});
$( "a.close-reveal-modal" ).click(function( event ) {
event.preventDefault();
var openElementClicked = "#" + $(this).parent().attr("id");
console.log(openElementClicked);
$(openElementClicked).foundation('reveal', 'close');
});
Upvotes: 0
Views: 709
Reputation: 7
I know this is an old thread, but thought I'd pass on this solution anyway.
To avoid the issue with IE, as @epascarello mentioned, we use a function called ltc
(log to console) which is sitting in our global.js library.
function ltc(what) {
try {
console.log(what);
} catch(e) {
return;
}
}
Now instead of using console.log("my message")
, it's simply ltc("my message")
;
Upvotes: 0
Reputation: 207501
console.log throws errors when the console is not open in IE.
Comment out the console lines or check for support
window.console && console.log(elementClicked);
Upvotes: 2