Firefox select dropdown keeps refreshing/reverting to default option due to running Javascript - AngularJS

后端 未结 4 1561
醉梦人生
醉梦人生 2021-02-12 22:52

I\'m building an app in AngularJS and am having trouble with select dropdown menus when using Firefox.

When I click a select menu and hover over the options, it resets

相关标签:
4条回答
  • 2021-02-12 23:31

    It seems like the creating the 'option' elements through ng-options is the root cause to this issue.

    I've altered the code a bit to make sure if that's the problem

    See the plunkr

    http://plnkr.co/edit/DLf2wvVGXRiwci6FhqQO?p=preview

    What I've done is to move the creation logic of the options to ng-repeat. That'll fix the issue for now.

    0 讨论(0)
  • 2021-02-12 23:40

    Please update the angularjs to v1.2.15

    http://plnkr.co/edit/pTnzpKAwFjugRVpuprFF?p=preview

    0 讨论(0)
  • 2021-02-12 23:40

    That's a AngularJS older version issue basically prior to 1.0.7, it's been fixed in 1.0.7 version, if you using anything older than 1.0.7 then you will be getting the same issue.

    0 讨论(0)
  • 2021-02-12 23:47

    Some people will still face this problem.

    Here is the fix:

     if (existingOption.id !== option.id) {
        lastElement.val(existingOption.id = option.id);
     }
    -if (existingOption.element.selected !== option.selected) {
    +if (existingOption.selected !== option.selected) {
          lastElement.prop('selected', (existingOption.selected = option.selected));
     }
    } else {
    

    Add this patch directly into the angular core. This bug still persists in v1.2.8

    0 讨论(0)
提交回复
热议问题