Skip to content

Instantly share code, notes, and snippets.

@DotNetNerd
Created May 8, 2013 08:15
Show Gist options
  • Save DotNetNerd/5539002 to your computer and use it in GitHub Desktop.
Save DotNetNerd/5539002 to your computer and use it in GitHub Desktop.

Revisions

  1. DotNetNerd created this gist May 8, 2013.
    14 changes: 14 additions & 0 deletions JsRx buffer clicks
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    .Add("/scripts/libs/rx.min.js")
    .Add("/scripts/libs/rx.time.min.js")
    .Add("/scripts/libs/rx.jquery.min.js")


    var observer = $(e.target).clickAsObservable().bufferWithTime(200)
    .subscribe(function (events) {
    console.log(events.length);
    var $item = $(e.target).closest('.productItem');
    var quantity = parseInt($.trim($item.find('.qty').html())) + events.length + 1;
    Basket.UpdateQuantity({ LineProductId: $item.attr('data-productId'), Quantity: quantity }, Basket.ShowQuantity);

    observer.dispose();
    });