The other solutions only work once on page load, if you want a solution that works on page load and page resize or orientation change for mobile. use this one.
var state = 'undefined';
$('#responsive-menu-button').sidr({
name: 'sidr-main',
source: '#navigation'
});
$('#responsive-menu-button').off('click').click(function(e){
e.preventDefault();
if(state == 'close'){
$.sidr('open','sidr-main', function(){ state = 'open'; });
} else {
$.sidr('close','sidr-main', function(){ state = 'close'; });
}
});
var deviceWidth = $(window).width();
var breakWidth = 480;
if(state == 'undefined'){
if(deviceWidth <= breakWidth) {
state = 'close';
} else {
setTimeout(function(){
$.sidr('open','sidr-main', function(){ state = 'open'; });
}, 100);
}
}
$(window).off('resize').bind('resize', function () {
deviceWidth = $(window).width();
if(deviceWidth > breakWidth && state == 'close') {
$.sidr('open','sidr-main', function(){ state = 'open'; });
}
if(deviceWidth <= breakWidth && state == 'open') {
$.sidr('close','sidr-main', function(){ state = 'close'; });
}
});