2

I have a product attribute named stone_weight. I'm trying to get the value of the attribute based on it's name name="product[stone_weight]" on change event. But it is not triggering any event. How can i properly use any event like change or keyup.

require.config({
 deps: [
 'jquery'
 ],
 callback: function ($) {
 $(document).ready(function(e){
 $('input[name="product\\[stone_weight\\]"]').change(function(e){
 $stone = $('input[name="product\\[stone_weight\\]"]').val();
 console.log($stone);
 });
 })
 }
 });
3
  • You have used net_weight instead of stone_weight in above code. Commented Dec 29, 2016 at 9:19
  • please share your code to get more help Commented Dec 29, 2016 at 11:36
  • Sorry. Question edited Commented Dec 29, 2016 at 12:12

1 Answer 1

2

You can try with below code,

 callback: function ($) {
 $(document).ready(function(e){
 $(document).on('change',$('input[name="product[stone_weight]"]'),function(e){
 $stone = $('input[name="product\\[stone_weight\\]"]').val();
 console.log($stone);
 });
 })
 }
answered Dec 29, 2016 at 12:27
2
  • Thanks for your help. It really helped me a lot. Kudos... Commented Dec 29, 2016 at 12:47
  • but it's preventing me from saving the value. It is saved as 0. Commented Jan 2, 2017 at 6:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.