Post by Shorty on Dec 6, 2012 22:15:29 GMT -8
So I'm working on a plugin that creates a custom post template. And everything is all fine and dandy, but I can't get the code to to return the values of the inputs. Can on your more experienced coders help me out on this issue? Thanks!!!
$(document).ready(function() {
if(proboards.data('route').params.board_id == proboards.plugin.get('custom_post_templates').settings.boards && (proboards.data('route').name == 'new_thread' || proboards.data('route').name == 'create_thread')) {
$('div.editor.ui-helper-clearfix').hide();
$('div.subject_line').after('<div class="templatetablediv" align="center"><table class="templatetable" width="100%"></table></div>');
var settings = proboards.plugin.get('custom_post_templates').settings;
var templatesAf = settings.custom_fields;
var nameWidth = settings.name_width;
var inputWidth = settings.input_width;
var descriptionWidth = settings.description_width;
var textareaheight = settings.text_area_height;
var postText = '';
for(i=0; i<templatesAf.length; i++) {
var field = templatesAf[i].what_type_of_field;
var name = templatesAf[i].name;
var description = templatesAf[i].description;
if(field == 'input') {
$('div.templatetablediv table.templatetable').append('<tr><td width="'+nameWidth+'">'+name+':</td><td width="'+inputWidth+'" style="text-align:left; padding-bottom: 3px;"><input type="text" style="width: 97% !important;" id="input'+i+'"></td><td width="'+descriptionWidth+'">'+description+'</td></tr>');
var inputval = $('div.templatetablediv table.templatetable tr td input#input'+i).val();
postText += '[b]'+name+':[/b] '+inputval+'
';
}
else if(field == 'text area') {
$('div.templatetablediv table.templatetable').append('<tr><td width="'+nameWidth+'" style="padding-bottom: 3px;">'+name+':</td><td width="'+inputWidth+'" style="text-align:left;"><textarea style="width: 97% !important; height: '+textareaheight+';" id="input'+i+'"></textarea></td><td width="'+descriptionWidth+'">'+description+'</td></tr>');
var textval = $('div.templatetablediv table.templatetable tr td textarea#input'+i).val();
postText += '[b]'+name+':[/b] '+textval+'
';
}
}
}
$('form.form_thread_new').submit(function() {
$('textarea[name="message"]').wysiwyg('setContent' , postText);
});
});