Skip to content

Instantly share code, notes, and snippets.

@webkader
Created July 13, 2015 20:59
Show Gist options
  • Save webkader/bd4f6804ee718fb6999a to your computer and use it in GitHub Desktop.
Save webkader/bd4f6804ee718fb6999a to your computer and use it in GitHub Desktop.
Simple Generator Code
var rownumber;
var $form_holder = "#renderForm";
var content = '';
var generatecode = function () {
var $this = '';
// the first loop for rows
$($form_holder + ' .fields').each(function (rownumber) {
var blockobject = '';
$this = $(this); //cache
var data_divide = $this.data('class');
$this.removeAttr("style");
var cls = (data_divide == "one") ? data_divide + ' blank' : data_divide + ' fields'
content += '\t<div class="' + cls + '">\n';
// the second loop for blocks
$this.children('.field').each(function () {
blockobject = $(this);
block_html = '\n\t\t<div class="field">\n';
var datafield = blockobject.find("label").data("id");
datafield = '%%' + datafield + '%%';
content += block_html + datafield + '\n\t\t</div>'; //close field
});
content += '\n\t</div>\n'; //close rows
rownumber = rownumber + 1;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment