1

I just want to get this jQuery to work. When I do this it writes to the console just fine:

$('body').on('submit', 'form[action="/cart"]', function(event){
  console.log("I don't think this is getting here");
});

But when I do this it doesn't write to the console:

$('body').on('change', 'form[action="/cart"]', function(event){
  console.log("I don't think this is getting here");
});

my test website anyone can see is at http://test-4658.myshopify.com this script is on the cart. You can add and update stuff in the cart to verify.

EDIT: Some other ideas I've tried, with no luck:

$('form[action="/cart"] :input').click(function() {
  if($(this).closest('form[action="/cart"]').data('changed')) {
  console.log("I don't think this is getting here");
  }
});

And:

$('body').on('change', 'form[action="/cart"] :input', function(event){
  console.log("I don't think this is getting here");
});

Where did I go astray?

14
  • 1
    I strongly suspect that the form element does not have a change event. You would have to change the selector to detect change on any input/select/textarea child of the form maybe. Commented Dec 30, 2016 at 19:11
  • 2
    Form change event does work, see example: jsfiddle.net/q6rzgzq4 -- must be something else Commented Dec 30, 2016 at 19:11
  • change event relies on the value of an element which forms don't have. Try monitoring for change on one of the form's elements/inputs. Commented Dec 30, 2016 at 19:12
  • makes sense.. let me see. but I thought that by using the form selector it selected all the child elements in the form? But maybe not.. Commented Dec 30, 2016 at 19:14
  • 1
    This might be a duplicate: stackoverflow.com/questions/3025396/… Commented Dec 30, 2016 at 19:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.