As correctly handle the event, if a lot of conditions and information is subject to change?

There is a task to write a calculator the final price. Displays a tree list price and when you select a particular item (checkbox or radio) final price varies. But in some positions when the choice should happen any unique event for example, the entire calculator is reset and selectable 3 position. Or other event which you want. The problem is that each item has its own id and it turns out I have to constantly watch what id to specific id to generate an event affecting other items with defined id-mi. That is just a very hard peg.

There is a solution - when filling out the price for a specific item to specify a callback function that will be executed when clicked. But I would like to hear other implementation.
June 14th 19 at 20:29
1 answer
June 14th 19 at 20:31
Solution
$('.price-line-switcher').on('change', function() {
 var $this = $(this);
 var $id = $this.attr('id');
 switch ($id) {
...
}
});
Thanks, but still remain the problems described above. - percy_Shanah commented on June 14th 19 at 20:34
If the actions can be formalized, you can instead switch to specify the desired id in the data that need to be reset/set when changing this switch.

If the actions are different, then write the logic in the handler. - Jerad_Padbe commented on June 14th 19 at 20:37

Find more questions by tags jQueryPHP