Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have some jQuery that resets the select/dropdown fields if the previous field is changed.

(我有一些jQuery,如果上一个字段被更改,它会重置选择/下拉字段。)

Sometimes if you click through the form for 30 seconds, and choose different options within the select/dropdown it'll freeze on a part of the form (usually the Location area of the form which you can see referenced as 'location-fill' in the code below).

(有时,如果您单击表单30秒钟,然后在选择/下拉菜单中选择其他选项,它将冻结在表单的一部分上(通常是表单的“位置”区域,您可以在其中将其称为“位置填充”下面的代码)。)

When commenting out the area I've named '2.

(在注释掉该区域时,我将其命名为'2。)

Resetting Fields', this does not happen.

(重置字段”,这不会发生。)

Is there something wrong with my code?

(我的代码有问题吗?)

I've included all my code for field resetting.

(我已经包含了所有用于字段重置的代码。)

    // 1. Resetting Fields
    age_select.on("change", function() {
        let currentCol = jQuery(this).val();
    // When age is changed reset other dropdown (by setting value to the default one)
    // and trigger change for the event handler to be called
        subject_select.attr("data-column", currentCol).val('subject-fill');
        area_select.attr("data-column", currentCol).val('location-fill');
    });

    //2. Resetting Fields - BELOW PART IS CAUSING THE FORM TO CRASH SOMETIMES 
    // if subject is changed reset location and trigger change
    subject_select.on("change", function() {
        area_select.val('location-fill').trigger('change');
    });

Thank you.

(谢谢。)

  ask by M.T translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
386 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...