I’m trying this:
$(document).ready( function() {
var myLayout = $('#layoutContainer').layout({
west__size: 450
, east__size: 250
});
function toggleFullView() {
myLayout.toggle('west');
}
$('#mapFooter').prepend('<a href="#" onClick="toggleFullView();" title="Toggle full view of map">Full View</a>');
}); // end document.ready
I keep getting an error ‘toggleFullView is not defined’ when I click the link created by the .prepend(). I’ve tried all sorts of messsing about. If I put the line from the toggleFullView function in the onClick i get the error – ‘myLayout is not defined’.
what to do? Thank you for your help.
This is because toggleFullView exists in the scope of the
.ready()callback, not the global scope of the script.You could also create the link and then attach an event handler with onclick and provide a callback.