Skip to content

Setting attribute value to undefined through bindingFilters #139

@jekuno

Description

@jekuno

The current implementation of the integer bindingFilter returns 0 for empty strings which is ok.
see: https://github.com/gmac/backbone.epoxy/blob/master/backbone.epoxy.js#L962

I want to add a bindingFilter which returns undefined for empty input fields (i.e. empty strings). It looks like this (CoffeeScript):

bindingFilters:
  integerOrUndefined:
    get: (value) ->
      if value then parseInt(value, 10) else undefined

     set: ( value ) ->
      if value then parseInt(value, 10) else undefined

If I use this bindingFilter and the user enters integers to the input fields the attribute value gets set correctly. If the user clears the input field the set function also correctly gets triggered and returns undefined as expected. However the according attribute never gets set to undefined.

I think this issue is due to a special handling of undefined values in backbone.epoxy. Is there any workaround for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions