Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide more customizable formatter and writers #127

Open
just-boris opened this issue May 20, 2016 · 1 comment
Open

Provide more customizable formatter and writers #127

just-boris opened this issue May 20, 2016 · 1 comment

Comments

@just-boris
Copy link

Syphon provides an ability to create custom input readers and writers for different data types. But type is always detected as tag name or type attribute. But sometimes I have to deal with custom data stored in the simple <input type="text">, but I still need to apply custom reader and writer for that fields.

Is there a way how to apply input readers and writers in the more customizable way? For example, add extra data-format attribute with additional information about field format.

@just-boris
Copy link
Author

just-boris commented May 20, 2016

Now I found a workaround with overriding default input reader and writer to add them more custom logic:

Backbone.Syphon.InputReaders.registerDefault(function($el) {
    var format = $el.data('format');
    var value = $el.val();
    if(format) {
        //custom format logic
    }
    return value;
});

Backbone.Syphon.InputWriters.registerDefault(function($el, value) {
     var format = $el.data('format');
     if(format) {
        //custom format logic
     }
     $el.val(value);
});

You can see full example here:
https://jsfiddle.net/just_boris/uw8hc7fb/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant