Giter Site home page Giter Site logo

formalizedata's People

Contributors

mazondo avatar michaelcbrook avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

formalizedata's Issues

Feature Request: Replace `data-type` with `data-formalize` that is just a function

Could register functions like this:

$.formalize.fn.toNumber = function(s){ return parseInt(s); }
$.formalize.fn.fromNumber = function(s){ return "" + s; }

Then the input field with data-formalize="number" could map to toNumber and fromNumber, or just number if it's available.

and users could add their own:

$.formalize.fn.toTimecode = function(s){ return (new TimecodeFromSeconds(s).timecode(); };
$.formalize.fn.fromTimecode = function(s){ return (new Timecode(s)).seconds(); };

Feature Request: Ability to set options to tweak each value

I'd like to be able to set a function option that lets me modify each value as it's coming in, or going out:

$("form").formaize({
  toData: function(value, options){ return parseInt(value)+1; },
  toForm: function(value, options){ return value-1; }
});
  • Not sure about names

Usability suggestions from reddit

Good idea.
I do suggest a small change though, for usability purposes.
Get rid of

if (!name) {
            throw "Elements must be named!";
        }

Change your .find() to include the attribute

.find("input[name], textarea[name]").each(

I also recommend passing the actual attribute name as a param.

$.fn.formalizeData = function(atName) {
atName = atName || "name";
in which case your .find() would be something like

.find("input[" + atName + "], textarea[" + atName + "]").each(

this way, if they want to use the default they can still call

.formalizeData()

and it would check for the 'name' attribute.
but if being used in a program that already uses a name attribute (as it is a common attribute)
they could say,

.formalizeData('data-name')

and it would look for the data-name attribute.
they could also create different combos of json data from a given form by utilizing different attributes

Feature Request: Ability to push a data object to the form

Once I have the data object, I'd like to be able to change it, and push it back to the form.

Maybe this interface:

// get the data
dataObj = $("form").formalize();

// do something with the data

// now set it
$("form").formaize(dataObj);

NOTE: It would have to know how to handle arrays, i.e. copy elements x times etc.

Feature request: Support non-form elements

I would like to be able to get data from a range of elements, decided by the selector on the active jQuery object.

Some examples:

var name = $("ul li.name input").formalize();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.