igCombobox, how do I prevent submisson if nothing selected?

150 views Asked by At

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.

2

There are 2 answers

0
Somepub On BEST ANSWER

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();
                 }
            }
0
Zdravko Kolev On

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.