Please look at your code:
var b = $('<a href=\''+(btn.url != '' ? btn.url : '#')+'\'></a>').appendTo(container);
If you are missing the 'url' property, the '<a href="undefined"...>' will be rendered and will navigate you to a undefined page. To solve this issue, please use this code instead.
var b = $('<a href=\''+(btn.url != undefined ? btn.url : '#')+'\'></a>').appendTo(container);
This example works fine.
http://code.reloado.com/ewecip3/edit#html,live