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:

  1. 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?
  2. practically speaking, how should controller respond_to (à la rails) depend on request format? is, how should application respond format.js, format.html or format.whatever in controllers when using rails framework?
  3. 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

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -