TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Stepping Backwards from AngularJS to JQuery – An Experiment

36 点作者 pcote超过 8 年前

9 条评论

carsongross超过 8 年前
<i>Giving up Angular did force me to think more about the DOM. Vanilla jQuery doesn&#x27;t insert itself as readily into HTML code as an Angular directive can.</i><p>And that&#x27;s why you should use <a href="http:&#x2F;&#x2F;intercoolerjs.org" rel="nofollow">http:&#x2F;&#x2F;intercoolerjs.org</a> for most of your stuff, and a bit of jQuery where necessary for more exotic UX needs. The people who got sick of a mess of jQuery code were right, but they went the wrong direction to fix it. We have to go back.<p>I know people get tired of my shilling, but intercooler really is a better way for many, and maybe most, web apps to be developed.
评论 #12384012 未加载
评论 #12385372 未加载
评论 #12384570 未加载
评论 #12384915 未加载
评论 #12390416 未加载
评论 #12385376 未加载
评论 #12384343 未加载
jasonkostempski超过 8 年前
I think there&#x27;s a better approach to handling the delete buttons that&#x27;s pretty common when using jQuery. Instead of each button having it&#x27;s own handler function I would specify an event handler on a single DOM element (e.g. a list container) with something like $(&#x27;#itemlist&#x27;).on(&#x27;click&#x27;, &#x27;.delete&#x27;, deleteItem). When &#x27;deleteItem&#x27; is called &#x27;this&#x27; will be the clicked button element that could have an attribute like &#x27;data-itemid=123&#x27; which you use to fill in the &#x27;id&#x27; part of the service call. And from there, after a successful service call, you can usually get at the parent element you want to remove from the list and take just that out instead of refreshing the entire list.<p>EDIT: Had the &#x27;on&#x27; parameters mixed up. Here&#x27;s the api doc: <a href="https:&#x2F;&#x2F;api.jquery.com&#x2F;on&#x2F;" rel="nofollow">https:&#x2F;&#x2F;api.jquery.com&#x2F;on&#x2F;</a>
评论 #12384445 未加载
impostervt超过 8 年前
I found this interesting because it seems to have been written by a person who learned Angular before jQuery. I haven&#x27;t run into that before.<p>Maybe I&#x27;m getting old.
评论 #12384130 未加载
评论 #12384083 未加载
评论 #12384873 未加载
评论 #12385276 未加载
评论 #12384198 未加载
jnbiche超过 8 年前
Next time, try dropping jQuery, too, and just using vanilla JavaScript. Just for fun. Simple DOM manipulation is now as simple in vanilla JavaScript as jQuery, with the only big advantage jQuery has now is if you&#x27;re animating. You may find you&#x27;re not missing much. You&#x27;d have to get used to slightly more involved Ajax syntax, unless you can target only new browsers, in which case the `fetch` API is just as convenient as jQuery&#x27;s Ajax.<p>Heck, if you can can transpile to ES6 or if you&#x27;re only targeting new browsers, you could probably even drop the Handlebars in factor of template literals without losing too much convenience.
评论 #12384381 未加载
评论 #12385092 未加载
评论 #12386169 未加载
评论 #12385229 未加载
评论 #12384199 未加载
pbreit超过 8 年前
Caveat: novice programmer here.<p>Even Angular is still difficult for me to grok and sometimes I wonder if stuff that comes out of Google &quot;suffers&quot; (for me) from Google having unlimited resources and employing superior engineers? Would Google have a difficult time empathizing with &quot;average&quot; programmers with limited resources?
评论 #12384655 未加载
评论 #12384220 未加载
评论 #12384223 未加载
评论 #12385083 未加载
评论 #12384351 未加载
评论 #12384377 未加载
nicolasMLV超过 8 年前
You can use event delegation for button handling : `$(document).on(&#x27;click&#x27;, &#x27;.button-list&#x27;, my_function);`<p><a href="https:&#x2F;&#x2F;learn.jquery.com&#x2F;events&#x2F;event-delegation&#x2F;" rel="nofollow">https:&#x2F;&#x2F;learn.jquery.com&#x2F;events&#x2F;event-delegation&#x2F;</a>
评论 #12384572 未加载
c-smile超过 8 年前
Just in case. I&#x27;ve written these while ago:<p>Routing, view, controllers in 60 lines of code + jQuery: <a href="https:&#x2F;&#x2F;github.com&#x2F;c-smile&#x2F;spapp" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;c-smile&#x2F;spapp</a><p>Template-less repeatable sections &#x2F; lists in 100 lines of code + jQuery: <a href="https:&#x2F;&#x2F;github.com&#x2F;c-smile&#x2F;repeatable" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;c-smile&#x2F;repeatable</a>.
matchagaucho超过 8 年前
Amazed at how Angular has created a generation of programmers that accept 2-way data binding and MVC as &quot;the only way&quot; to develop web apps.<p>JQuery encourages more fluent, purely functional reasoning, and one-way data binding of immutable data objects.
评论 #12385553 未加载
asciihacker超过 8 年前
Step forward to ScalaJS and dont look back?<p><a href="https:&#x2F;&#x2F;www.scala-js.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.scala-js.org&#x2F;</a>