简体   繁体   中英

igCombobox, how do I prevent submisson if nothing selected?

I have an igCombobox "checkbox", when nothing is selected it still submits the form, which I dont want to happen.

I'm using this code to submit:

 <div id="checkboxSelectCombo" name="kanal" style="position:absolute;" ></div>

 $("#checkboxSelectCombo").on( "focusout",function() {
  $(this).closest("form").submit();
     });

So, I tried to use if statement, if value is greater than zero or is not an empty string

$("#checkboxSelectCombo").on( "focusout",function() {
             if($(this).val()>0 || $(this).val()!=""){
  $(this).closest("form").submit();}
     });

But since I cant get the value from checkboxSelectCombo it wont work. I already searched igCombobox documentation, but didn't find anything.

As I see you are submitting the form on every focus out. You can perform the submit on selectionChanged event or dropDownClosed for example. From these events you can access the items list or to perform some checks. Keep in mind that they are not cancellable.

I found a solution to my problem. As Zdravko Kolev said that I should use dropDownClosed, I was able to prevent submit without selecting anything on the igComboBox with this code

 dropDownClosed: function (evt, ui) {
                var dpValue = ui.owner.value();  
                 if(dpValue != 0){                 //dpValue>0
                $(this).closest("form").submit();
                 }
            }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM