JQuery Cascade plugin dropdown does not refresh

前端 未结 1 566
名媛妹妹
名媛妹妹 2021-02-11 05:11

I\'m using the JQuery based Cascade plugin; probably it\'s working, but I found a lot of problems with it.

Maybe somebody already faced with this plugin and maybe could

相关标签:
1条回答
  • 2021-02-11 05:48

    The problem with the original plugin code is that it doesn't fire the change event after it manipulates the dropdown.

    Also, I like to think of this problem in terms of 'dependency' and not 'cascading'. I have tried to create a simple plugin and a demo page which shows how the whole thing works.

    Demo: http://jsbin.com/unope

    Code: http://jsbin.com/unope/edit

    Let me explain what I have done. I have created the plugin named 'dependent' which lets you associate dependency for a drop down.

    e.g.

    $('#dropDown2').dependent({ 
                                dependency : 'dropDown1',
                                values : getValues
                            });
    

    Above code suggests that dropDown2 is dependent on dropDown1, so whenever dropDown1 value changes, it will call your getValues function (passing it dropDown1). You should return relevant values from your getValues function and it will populate them in dropDown2.

    Keep in mind that this code is not generic, I have quickly wrote it to demonstrate the concept. You will have to tweak it further to achieve your desired result.

    Let me know if you have any questions.

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