I need to check for an attribute inside the Jquery Mobile transition data object. The attribute can either be undefined or has a value of dialog or some other value.
Originally I only checked like this:
$(document).on( "pagebeforechange", function( e, data ) {
if( A && B && data.options.role != "dialog" ){
// do something
}
});
However, this way I never enter the if-clause when data.options.role is undefined. I'm currently trying like this but am not really getting anywhere:
$(document).on( "pagebeforechange", function( e, data ) {
if( A && B && data.options.role != "undefined" && data.options.role != "dialog" ){
// do something
}
});
Question
How can I make sure the value is queries and passes into the IF clause if it's either undefined or has a value, which is not dialog?
Thanks for help!
data.options.roleisundefined, then your first if statement should be hit. What areAandBlooking for?AandBare true? You can see from the following fiddle that your original condition is hit when.roleis undefined: jsfiddle.net/RoryMcCrossan/NSDgL/1