I have uploaded a .csv full of contact information for various partner businesses in my app. I am using a REST service to send the ID and populate each business' page by entering the string values of each cell into corresponding labels. This is working great. However, not all businesses have all the information. For example, some are missing a website. As a result, I get something like:
Name: Business Name
Phone: (123) 456-7890
Email: a href="mailto:example@email.com" rel="nofollow"example@email.com/a
Website: undefined
I would like to use an if statement to make the field go invisible if the result is undefined. This is what I initially tried:
if(Appery(“bizWeb").text == "undefined"){
Apperyio('bizWeb').hide();
} else {}
If the label text reads "undefined" (which it does), then it should hide the label. However, despite the fact that the label displays "undefined", when I use an alert to show what Appery.(bizWeb).text actually contains, it shows me this function:
"function ( value ) {
var hooks, ret, isFunction,
elem = this[0];
if ( !arguments.length ) {
if ( elem ) {
hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
Code: Select all
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
return ret;
}
ret = elem.value;
return typeof ret === "string" ?
// handle most common string cases
ret.replace(rreturn, "") :
// handle cases where value is null/undef or number
ret == null ? "" : ret;
}
return;
}
isFunction = jQuery.isFunction( value );
return this.each(function( i ) {
var val,
self = jQuery(this);
Code: Select all
if ( this.nodeType !== 1 ) {
return;
}
if ( isFunction ) {
val = value.call( this, i, self.val() );
} else {
val = value;
}
// Treat null/undefined as ""; convert numbers to string
if ( val == null ) {
val = "";
} else if ( typeof val === "number" ) {
val += "";
} else if ( jQuery.isArray( val ) ) {
val = jQuery.map(val, function ( value ) {
return value == null ? "" : value + "";
});
}
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
// If set returns undefined, fall back to normal setting
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
this.value = val;
}
});
}"
not "undefined". Any ideas? I'm sure that I'm just going about this all wrong.