3 ms·
Honestly, there's not a huge amount of difference between <a href="#" id="show-help-link">Show Help</a> <script src="text/javascript"> $("#show-help-li
by avolcano 14y ago
Honestly, there's not a huge amount of difference between
<a href="#" id="show-help-link">Show Help</a>
<script src="text/javascript">
$("#show-help-link").click(function() { showHelp(); } );
</script>
And
<a href="#" ng-click="showHelp()">Show Help</a>
I mean, HTML has behavior in it. A link in itself is "behavior": when you click this tag, go to the page defined in the src attribute. So, as the author says, it's not really a bad thing that templates have behavior in them. In Ember.js, for example, you have an {{action}} handler that is essentially the same as ng-click - "run a function on the controller when this is clicked."
- d0m 14y agoI think it's because needs evolved. When we went away from tables to use stylesheets, the goal was to keep the same html but alter the presentation with css and js (for the animations). But now, it's not just about presentation anymore. Real applications are built and maybe it doesn't make sense to keep the html and throwing away css/javascript on a full-rewrite. Basically, the html we code right now is way more tied to the javascript that it once was. So, having them in two separate files doesn't make that much sense. Oh, and, you can use $('#show-help-link').click(showHelp); instead of click(function() { showHelp(); }); ! : )
- sgt 14y agoYou don't need the src="text/javascript". Only <script> ... </script> is required.
- avolcano 14y agoHeh, I meant to specify "type" and not "src", but you're right regardless.