Guest User

Untitled

a guest
Dec 12th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. # Making a reusable, extendable table widget with marionette that supports CRUD
  2.  
  3. I work on a mainly server-side, horribly complex, and quite large (247 kloc) rails app. Re-use of components and testability are probably our biggest concerns. I want to introduce the team to Backbone and Marionette, so this will take place during an extended lunch and learn. Probably won't TDD it due to the amount of content I want to cover
  4.  
  5. ## steps
  6.  
  7. first, need to make a basic editable table
  8.  
  9. - Make a composite view (table/container), creator view (for "new" row), and item view (for "edit/show" of rows)
  10. - Item view overrides getTemplate to switch between edit/show modes
  11. - Composite takes a creator view, instanciates it, and renders it along with its own render
  12.  
  13. next, make it generic
  14.  
  15. - switch initialize/onRenders to constructor/render and "call super" appropriately on all views
  16. - make a factory for the composite view that
  17. - takes item view, create view, collection
  18. - also can take editTemplate, rowTemplate, createTemplate, and urlRoot
  19. - need to have one or the other for any given "thing" (meaning, either a createTemplate or a createView is nessicary for example), if it is the more "light weight" versions, then the factory builds the classes required, setting the passed in manditory attrs
  20. - make a jquery plugin that takes all 7 options, invokes the factory, instanciates and renders the view, appends it to selected element, and adds it to the elements .data
  21.  
  22. ## benefits
  23.  
  24. - Simple cases you can very easily get a ton of functionality
  25. - If you want to have additional functionality for a given sub-component, it is very simple to make your own view and add it
  26. - Nice separation of concerns
  27. - Easy to test
  28. - Easy to reuse
  29. - Loads of functionality for relatively little code
Add Comment
Please, Sign In to add comment