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

Need to change implementation of default options #13

Open
farias-r7 opened this issue Feb 23, 2015 · 0 comments
Open

Need to change implementation of default options #13

farias-r7 opened this issue Feb 23, 2015 · 0 comments

Comments

@farias-r7
Copy link
Contributor

The current approach to default options is problematic. If we create multiple instances of carpenter on a page and change the default options, due to how prototypes behave the changed config options will bleed through to other instances of the table controller. This will cause unexpected behavior.

The fix is to adopt the defaults pattern used by Brian Mann. Previous references to the prototypes in the table controller must now be prefixed with @config.

@config.selectable
@config.filterTemplatePath

Original:

 class Marionette.Carpenter.Controller extends Controller

      # @property [Boolean] allow checkbox selection of table rows
      selectable: false

      # @property [String] the path to the (optional) template for the Filter view
      filterTemplatePath: ''

      # @property [Boolean] allow rows in the table to be tagged
      taggable: false

      # @property [String] text to show in the table header
      title: null

      # @property [Boolean] do not use AJAX to sync the models
      static: false

      # @property [Boolean] fetch collection on initialization
      fetch: true

      # @property [String] attribute name of the default sorted column
      #   Defaults to the first sortable column if this property is null.
      defaultSort: null

New:

 class Marionette.Carpenter.Controller extends Controller

      defaults: ->
        selecatable: @selectable
        filterTemplatePath: @filterTemplatePath
        .....
        .....
        .....

      # @property [Boolean] allow checkbox selection of table rows
      selectable: false

      # @property [String] the path to the (optional) template for the Filter view
      filterTemplatePath: ''

      # @property [Boolean] allow rows in the table to be tagged
      taggable: false

      # @property [String] text to show in the table header
      title: null

      # @property [Boolean] do not use AJAX to sync the models
      static: false

      # @property [Boolean] fetch collection on initialization
      fetch: true

      # @property [String] attribute name of the default sorted column
      #   Defaults to the first sortable column if this property is null.
      defaultSort: null
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