Author Topic: Resetting pqSelects programmatically  (Read 4446 times)

vikerii

  • Newbie
  • *
  • Posts: 2
    • View Profile
Resetting pqSelects programmatically
« on: May 06, 2015, 01:38:32 am »
Hi,

I have a series of pqSelects in a div.  When a user clicks a 'Reset' button, I'd like to reset all the pqSelects to their first option (aka selectedIndex==0).  I don't see any pqSelect method for doing this. Is it even possible? 

For example:
$(divID).find('.pq-select').pqSelect("select", 0);

Thanks,
Mike

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Resetting pqSelects programmatically
« Reply #1 on: May 06, 2015, 02:16:51 pm »
yes it's possible to reset, it's answered here: https://github.com/paramquery/select/issues/2

Hope it helps.
« Last Edit: May 06, 2015, 06:13:50 pm by paramquery »

vikerii

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Resetting pqSelects programmatically
« Reply #2 on: May 08, 2015, 08:00:34 pm »
Thanks, that helped.  I added it as a new method for the pqselect:

    fn.reset = function () {
        if (this.multiple) {
            this.element.val([]);
        } else {
            this.element.prop('selectedIndex', 0);
        }
        this.refreshData();
    };