developer_cz Developer Da Czech Republic Membro dal apr 2018 developer_cz 15 ott 2020 13:16 Selecting/changing shipping method in checkout - it is possible to catch via JS/jQuery (any event)? I need to detect selected shipping method/module and trigger another event via JS/jQuery. How best to do it? Thanks for help.
tim Founder Da Sweden Membro dal mag 2013 tim 15 ott 2020 15:51 Use regular jQuery Events: alert('You clicked option: ' + $(this).val()); });``` This willl not work as the content is refreshed by ajax and the set events are lost upon that refresh: ```$('input[name="shipping[option_id]"]').change(function(){ alert('You clicked option: ' + $(this).val()); });```
developer_cz Developer Da Czech Republic Membro dal apr 2018 developer_cz 15 ott 2020 16:36 I've tried that, but it doesn't work in Google Chrome or in any other browser. I found "There's no reliable cross-browser event that gets fired when the content of a DIV (as opposed to a form element, say) changes.".
tim Founder Da Sweden Membro dal mag 2013 tim 15 ott 2020 20:05 You are right, "click" as an event works but not change. I wonder why.
developer_cz Developer Da Czech Republic Membro dal apr 2018 developer_cz 15 ott 2020 21:32 I spent several hours doing this, but I could not find a solution. Manually triggering a change event on the input (shipping[option_id]) is probably the only one solution.
tim Founder Da Sweden Membro dal mag 2013 tim 16 ott 2020 01:34 Click should do if you check the check state between the clicks. Still, I'm very surprised. The radio buttons are hidden, but the label wrapper should delegate the onchange event. Try triggering the event like this: In includes/templates/default.catalog/pages/checkout.inc.php Find $(this).find('input[name="shipping[option_id]"]').prop('checked', true); Replace with $(this).find('input[name="shipping[option_id]"]').prop('checked', true).trigger('change');
developer_cz Developer Da Czech Republic Membro dal apr 2018 developer_cz 16 ott 2020 09:59 Thanks, that's the solution. Great. One last step - can you take a look at [url=https://www.litecart.net/en/forums/2/general-discussions/1373/how-to-pass-something-from-shipping-module-to-order#1386][/url][url=https://www.litecart.net/en/forums/2/general-discussions/1373/how-to-pass-something-from-shipping-module-to-order#1386]this topic[/url]?