ruby on rails - Some questions on Unobtrusive JavaScript -
i using ruby on rails , heard of “unobtrusive javascript” (ujs). after (but before) my previous question, ask myself:
- are there common-used patterns, rules, practices or techniques in order respond pragmatically javascript , html ajax requests? if there are, those? example, responses should returned? kind of data? there standard?
- practically speaking, how should controller
respond_to
(à la rails) depend on request format? is, how should application respondformat.js
,format.html
orformat.whatever
in controllers when using rails framework? - about previous matters, solution of rails community , / or of “general” public? use?
ajax
i don't know patterns, take "per feature" stance -
you'll have different use cases different features. in part, can handle these using remote: true
option (which uses ajax handler in ujs), allow either capture response .on("ajax:success"
in asset js, or using .js.erb
file in backend
the bottom line produce least amount of code. @ perspective of future development - in future, confused we're doing, or logical way?
i suppose find more structured way of handling this, varying amounts of data coming back, prefer handle each feature in own way
--
code
i put code efficiency & focus functionality first
instead of trying make pattern fit cases, i'd @ you're trying achieve, , creating code work. if can refactor after that, great! otherwise, i'd invest energy getting functionality working
Comments
Post a Comment