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);
});
})
}
});
-
You have used net_weight instead of stone_weight in above code.Rakesh Jesadiya– Rakesh Jesadiya2016年12月29日 09:19:37 +00:00Commented Dec 29, 2016 at 9:19
-
please share your code to get more helpRakesh Jesadiya– Rakesh Jesadiya2016年12月29日 11:36:53 +00:00Commented Dec 29, 2016 at 11:36
-
Sorry. Question editedShiyas Pathiyassery– Shiyas Pathiyassery2016年12月29日 12:12:16 +00:00Commented Dec 29, 2016 at 12:12
1 Answer 1
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
Rakesh Jesadiya
42.5k19 gold badges135 silver badges186 bronze badges
-
Thanks for your help. It really helped me a lot. Kudos...Shiyas Pathiyassery– Shiyas Pathiyassery2016年12月29日 12:47:22 +00:00Commented Dec 29, 2016 at 12:47
-
but it's preventing me from saving the value. It is saved as 0.Shiyas Pathiyassery– Shiyas Pathiyassery2017年01月02日 06:01:34 +00:00Commented Jan 2, 2017 at 6:01
Explore related questions
See similar questions with these tags.
default