-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught TypeError: Cannot set property 'w' of undefined #1
Comments
and the solution seems to be:
embedding the plugin right after jquery. previously i had it at the end of my plugin list... not sure if it is still a bug... |
It happens if you bind resize events before ba-resize is loaded, so this event won't get |
I had changed new_handler but this is probably hacky... ...
function new_handler( e, w, h ) {
var elem = $(this),
data = $.data( this, str_data );
// added this bit
if (!data) {
data = $.data( this, str_data, { w: elem.width(), h: elem.height() })
}
else {
// If called from the polling loop, w and h will be passed in as
// arguments. If called manually, via .trigger( 'resize' ) or .resize(),
// those values will need to be computed.
if (w !== undefined) {
data.w = w
}
else {
data.w = elem.width();
}
data.h = h !== undefined ? h : elem.height();
}
old_handler.apply( this, arguments );
}; |
My script was included after jquery but not immediately after. |
Maybe this would be better: function new_handler( e, w, h ) {
var elem = $(this),
data = $.data( this, str_data );
if (!data) {
data = $.data( this, str_data, {})
}
// If called from the polling loop, w and h will be passed in as
// arguments. If called manually, via .trigger( 'resize' ) or .resize(),
// those values will need to be computed.
data.w = w !== undefined ? w : elem.width();
data.h = h !== undefined ? h : elem.height();
old_handler.apply( this, arguments );
}; |
I had a similar issue but it wasn't because the plugin wasn't loaded. (Using require.js) The above patch by MikeAmy seems to have fixed my problem. |
MikeAmy's solution above also fixed my issue of "data" being undefined. Insert the if block: if (!data) {
data = $.data( this, str_data, {})
} after line 193 in jquery.ba-resize.js. |
MikeAmy's solution it's still working pretty good, thanks! |
What is the status of this issue? I am seeing the same error. |
@tobiaz fix also fixes my problems. But I just found out that the last commit to this repo was 4 years ago: so I am abonding it. |
MikeAmy's solution is useful. Thank you. |
i get the following error in chrome/firefoxIE8
my implementation:
$(".container").resize(function(e){
setTimeout(function() { console.log('resize') }, 10);
});
The text was updated successfully, but these errors were encountered: