0

I have a text input using .keyup to active a .livequery on an ajax load. The problem is, the user has to click outside of the box to active the keyup function. Is it possible to simulate a keyup function while typing?

Here's what I have:

        $('.input-mini').keyup().livequery('change', function () {
                url = $(this.form).attr('action');
                data = $(this.form).serialize();
                $.post(url, data, function () {
                        $('#checkout').load('/store/checkout_table');
                        $('#checkout_form').attr('action', url);

            $.cookie('all_cookie', null);

                });
                return false;
        });
Denny Smith
  • 113
  • 1
  • 10
  • I don't get it. Why exactly are you using liveQuery and not just a delegated event handler, and why are you doing a post request when you don't return anything, and then another request with load() in the success callback. This just does'nt make much sense, and you could even just do `livequery('keyup', function() { ... });`, I just don't see why ??? – adeneo Mar 27 '13 at 12:54
  • I'm attempting to load a shopping cart change. When a user changes their input, I need to re-calculate shipping. So, say they entered the cart with 30 items it sends and ajax request via api for live shipping rates and displays a response. If they change it to 20, , on keyup, I'm recalculating their shipping with a different response without refreshing the page. At least I'm attempting to. That worked perfectly, Thanks! – Denny Smith Mar 27 '13 at 13:32

1 Answers1

0

try this

$('.input-mini').keyup(function(){
  $(this).livequery('change', function () {
  ....
})
bipen
  • 36,319
  • 9
  • 49
  • 62