Sha256: 4bf750142090920b21d86e0e5536be4d3d072565cb4bc3b4ea34c830bc047272
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
o_O.find_attributes = function(template, callback){ var object = {}; for(i = 0; i<template.find('[data-attribute]').length; i++) { field = $(template.find('[data-attribute]')[i]); object[field.attr('data-attribute')] = callback(field); } return object; } o_O.params = function(form){ return o_O.find_attributes(form, function(field){ if(field.is('[type=radio]')) { return $('[data-attribute=' + field.attr('data-attribute') + ']:checked').val() } else { return field.val(); } }); } o_O.render = function(template, data, options){ o_O.get_template(template, data, function(data, template){ var rendered = Mustache.to_html(template, data); if(typeof options === 'object') { if(options.append) { $(options.append).append(rendered); } if(options.prepend) { $(options.prepend).prepend(rendered); } if(options.replace) { $(options.replace).replaceWith(rendered); } if(options.html) { $(options.html).html(rendered); } } }); } o_O.get_template = function(template, data, callback){ if(o_O.templates[template]) { callback(data, o_O.templates[template]); } else { var url; if(o_O.config.template_path) { url = o_O.config.template_path + '/'; } else { url = 'app/views/' } $.get(url + template + '.html.mustache', function(response){ o_O.templates[template] = response; callback(data, response); }); } }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
eyeballs-0.5.10.1 | src/drivers/jquery/modules/o_O.support.js |
eyeballs-0.5.10 | src/drivers/jquery/modules/o_O.support.js |