Get selected image URL from wp.media.editor.attachment into text input fails. What am I doing wrong?

Apparently there was a conflict in the complex string

$("#mb-socialimg").val(wp.media.attachment(attachment.id).get("url")+"|"+attachment.id);

I changed to the following and now it all works well

$("#mb-socialimg").val(attachment.url+"|"+attachment.id);