タグ

JavaScriptとjQueryに関するmasayoshinymのブックマーク (25)

  • AngularJSではjQueryを使わない - The Round

    注:古い記事の為、内容が最新ではない可能性がありますm(_ _)m AngularJSではjQueryを使わない どうもマツウラです。 AngularJSでjQueryプラグインを使う方法を調べました。 結論から書くとなるべくdirectiveで書きなおして下さい、ということです。 プラグインをそのまま使いたい気持ちはありますが、理由があるんです。 まず、AngularJSで使う方法をみてみます。 プラグインが適用されない。 directiveのlink関数に書く。 .directive('myDirective', function() { return { link: { post: function(scope, element, attr) { //... } } } }) 動的に生成されたDOMに対してプラグインが適用されない。 $timeoutを使う。 $timeout(fun

    AngularJSではjQueryを使わない - The Round
  • jQueryの.bind(), .live(), .delegate()の違い

    The Difference Between jQuery’s .bind(), .live(), and .delegate() - Alfa Jango Blog http://www.alfajango.com/blog/the-difference-between-jquerys-bind-live-and-delegate/ jQueryの.bind(), .live(), .delegate()違いや仕組みの理解、また.delegate()の方が.live()より優れている理由について書かれています。 内容を簡単に書き出すと以下のようなことについて書かれています。 $('a').bind('click', function() { alert("That tickles!") }); .bind()は$(‘a’)に対してイベントを設定してる。 $('a').live('clic

    jQueryの.bind(), .live(), .delegate()の違い
  • event.preventDefault() vs. return false

    When I want to prevent other event handlers from executing after a certain event is fired, I can use one of two techniques. I'll use jQuery in the examples, but this applies to plain-JS as well: 1. event.preventDefault() $('a').click(function (e) { // custom handling here e.preventDefault(); }); 2. return false $('a').click(function () { // custom handling here return false; }); Is there any signi

    event.preventDefault() vs. return false
  • event.preventDefault() vs. return false (no jQuery)

    I wondered if event.preventDefault() and return false were the same. I have done some tests, and it seems that If the event handler is added using old model, for example elem.onclick = function(){ return false; }; Then, return false prevents default action, like event.preventDefault(). If the event handler is added using addEventListener, for example elem.addEventListener( 'click', function(e){ re

    event.preventDefault() vs. return false (no jQuery)
  • jQuery.ajax(options) - jQuery 日本語リファレンス

    HTTP通信でページを読み込みます。 この関数はjQueryにおけるAJAX通信の基部分で、実際には$.getや$.postといった関数を使った方が、容易に実装できます。 但し、これらの抽象化された関数は実装の容易さと引き換えに、エラー時のコールバックなどの複雑な機能を失っています。そのような処理を実装したい場合は、やはり基幹であるこの関数を用いる必要があります。 $.ajax関数は、戻り値として XMLHttpRequestオブジェクトを返します。殆どの場合、このオブジェクトを直接操作することは無いと思われますが、例えば投げてしまったリクエストを中断する場合など、必要であれば利用して下さい。 この関数は引数をひとつだけとりますが、実際にはハッシュで、キーと値の組み合わせにより多くのオプションを受け取ります。 以下にその一覧を載せますので、参考にして下さい。 async / boolea