The problem is here.
var title = jQuery('.Title').val(), content = jQuery('.Content').val(), shortcode += '[tap ';
shortcode already the var defined above. You cannot use += in a var statement
Just change it to
var title = jQuery('.Title').val(), content = jQuery('.Content').val();
I think you will also face the problem of nesting. Instead of calling jQuery('.Content').val() for each iteration of the loop, I think you are looking for something like $(this).find('.Content').val() or $('.Content', this) This will find the corresponding .Content entry in the scope of the specified .tapForm .
I think about it, but it's just an idea.
jQuery('body').on('click', '#tapSubmit', function(){ function title(context) { var value = jQuery(".Title", context).val(); return value ? 'title="' + value + '"' : ''; } function content(context) { var value = jQuery(".Content", context).val(); return value || ''; } var taps = jQuery('.tapForm').map(function(){ return '[tap ' + title(this) + ']' + content(this) + '[/tap]'; }).join(); tinyMCE.activeEditor.execCommand('mceInsertContent', false, '[tapWrap]' + taps + '[/tapWrap]'); });
source share