How to reset select box with jquery using selectboxit

dmikester1

I am using Fancybox to pop up a div in the middle of the page that has a select box styled with the selectboxit jquery plugin here: http://gregfranko.com/jquery.selectBoxIt.js/. Now I change the select value to something other than the default and close the Fancybox. When I reopen that Fancybox, the select value is still the same as what I had selected. I need it to reset to the default. Here is the javascript coode that I have right now:

var selectBox = $("select").selectBoxIt();
        $(".fancybox, #cartLink").fancybox({
            width: 800,
            autoHeight: true,
            minHeight: 385,
            scrolling: 'no',
            autoSize: false,
            afterClose: function () {
                $(selectBox).val('0');
                $(selectBox).refresh();
                console.log('should be reset!');
            }
        });

The first two lines in the 'afterClose' function do not work. The first might be doing something but the refresh line says this in Firebug: "TypeError: $(...).refresh is not a function $(selectBox).refresh();" Any ideas how I can reset this selectbox?

Edit: As requested, here is a fiddle: http://jsfiddle.net/Qh2NP/1/

Greg Franko

You can use the SelectBoxIt selectOption() method. Like this:

 $(document).ready(function () {
     var selectBox = $("select").selectBoxIt();
     $("#cartLink").fancybox({
         width: 800,
         autoHeight: true,
         minHeight: 385,
         scrolling: 'no',
         autoSize: false,
         afterClose: function () {
             $(selectBox).selectBoxIt('selectOption', 0);
             $(".notification").hide();
             console.log('should be reset!');
         }
     });
 });

Here is a link to your updated jsfiddle: http://jsfiddle.net/Qh2NP/2/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to trigger the native select box using SelectBoxIt jquery plugin

From Dev

How to set first option's of Select Box using jQuery?

From Dev

How to display data in select box option using jquery

From Dev

Using Jquery how do i validate Select box in this situation?

From Dev

How to display data in select box option using jquery

From Dev

How to get the key of a multi diamentional select box using jQuery

From Dev

Reset select box value

From Java

How to reset a form using jQuery with .reset() method

From Dev

Selectboxit - How to refresh selected values in selectboxit

From Dev

Selectboxit - How to refresh selected values in selectboxit

From Dev

Using SelectBoxIt in AngularJS Directive

From Dev

Reset input box fields on each time using jQuery

From Dev

Populating a select box using JQUERY, AJAX and PHP

From Dev

Hiding Elements with JQuery using a select box

From Dev

Hiding Elements with JQuery using a select box

From Dev

Unable to validate multiple select box using jQuery

From Dev

Using a select option to populate input box with JQuery

From Dev

how can i call select box on change while changing select value using jquery?

From Dev

How do I select all check box when I click on Select button using jQuery

From Java

Select a value from a select box and auto select a value from another select box using jquery

From Dev

How to filter select box options with jQuery?

From Dev

How to style jquery chosen select box

From Dev

How to get select box name in jquery

From Dev

How can I get bunch of selected ids from select box using jquery

From Dev

How to reset a css animation class using jquery?

From Dev

How to change the image using select box in angular?

From Dev

How to Customize a multiple Select box using CSS

From Dev

Not able to reset the values of form elements on change of select box in struts2 jquery

From Dev

Not able to reset the values of form elements on change of select box in struts2 jquery

Related Related

  1. 1

    How to trigger the native select box using SelectBoxIt jquery plugin

  2. 2

    How to set first option's of Select Box using jQuery?

  3. 3

    How to display data in select box option using jquery

  4. 4

    Using Jquery how do i validate Select box in this situation?

  5. 5

    How to display data in select box option using jquery

  6. 6

    How to get the key of a multi diamentional select box using jQuery

  7. 7

    Reset select box value

  8. 8

    How to reset a form using jQuery with .reset() method

  9. 9

    Selectboxit - How to refresh selected values in selectboxit

  10. 10

    Selectboxit - How to refresh selected values in selectboxit

  11. 11

    Using SelectBoxIt in AngularJS Directive

  12. 12

    Reset input box fields on each time using jQuery

  13. 13

    Populating a select box using JQUERY, AJAX and PHP

  14. 14

    Hiding Elements with JQuery using a select box

  15. 15

    Hiding Elements with JQuery using a select box

  16. 16

    Unable to validate multiple select box using jQuery

  17. 17

    Using a select option to populate input box with JQuery

  18. 18

    how can i call select box on change while changing select value using jquery?

  19. 19

    How do I select all check box when I click on Select button using jQuery

  20. 20

    Select a value from a select box and auto select a value from another select box using jquery

  21. 21

    How to filter select box options with jQuery?

  22. 22

    How to style jquery chosen select box

  23. 23

    How to get select box name in jquery

  24. 24

    How can I get bunch of selected ids from select box using jquery

  25. 25

    How to reset a css animation class using jquery?

  26. 26

    How to change the image using select box in angular?

  27. 27

    How to Customize a multiple Select box using CSS

  28. 28

    Not able to reset the values of form elements on change of select box in struts2 jquery

  29. 29

    Not able to reset the values of form elements on change of select box in struts2 jquery

HotTag

Archive