Note that there are some explanatory texts on larger screens.

plurals
  1. POMy JavaScript patterns/practices stink. Where should I seek help?
    primarykey
    data
    text
    <p>I've been working almost exclusively on back-end tasks for the past few years, and I've just noticed that most JavaScript (and CoffeeScript) projects have got a helluva lot prettier in my absence. </p> <p>I work primarily in a rails environment, and almost all my JavaScript/jQuery used to look like this:</p> <pre><code>$(an_element).an_event(function() { stuff_i_want_to_do; }) $(another_element).some_other_event(function() { some_other_stuff_i_want_to_do; }) </code></pre> <p>Callbacks aside, that's pretty much been it.</p> <p>Anyhow, was just browsing through some other folks' code and noticed many javascripters have been getting a lot prettier in my absence. This isn't complex, but it's typical of the newer/better approach to JavaScript I've been seeing:</p> <pre><code>jQuery -&gt; if $('#products').length new ProductsPager() class ProductsPager constructor: (@page = 1) -&gt; $(window).scroll(@check) check: =&gt; if @nearBottom() @page++ $(window).unbind('scroll', @check) $.getJSON($('#products').data('json-url'), page: @page, @render) # nearBottom: =&gt; $(window).scrollTop() &gt; $(document).height() - $(window).height() - 50 render: (products) =&gt; for product in products $('#products').append Mustache.to_html($('#product_template').html(), product) $(window).scroll(@check) if products.length &gt; 0 </code></pre> <p>I've been looking for resources on modern best practices/patterns for JavaScript (and/or CoffeeScript), but I haven't had much luck. So in short, where should I look to be brought up to speed re: best javascript/coffeescript modern patterns &amp; practices?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload