This is some jQuery I use to create links out of system-generated comma separated lists and it always works well.
In a very special circumstance I need the script to add an iframe and open the link in it. I've come up with the following but can't get it to work. My question is, is it possible to push the script to work this way? And if so, where am I going wrong?
JQuery
$('.assigns').each(function() {
var obj = $(this),
assigns = obj.text().split(','),
i = 0,
len = assigns.length;
if (obj.text()) {
for (i; i < len; i++) {
var assign = assigns[i].replace(/(^\s*)|(\s*$)/g, '');
if (assign != "") {
assigns[i] = '<a onclick="$(' <iframe style="width: 100%; height: 5.5em;" scrolling="no" name="frame" src="http://www.example.com"></iframe>').appendTo('#assign_frame');" title="Assign to '+assign+'" class="button_main_build">'+assign+'</a>';
}
}
obj.html(assigns.join(' '));
}
});
The HTML
<div id="assign_frame"></div>
<p class="assigns">Bob Jones, Tom Smith, John Appleseed</p>