EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on March 25, 2015, 04:14:05 PM



Title: Select the parent tab of a required input & show validation message
Post by: devnull on March 25, 2015, 04:14:05 PM
Hi;

How can I find the Parent Tab Index or Tab Text of an element in that tab.

For example if I have an input element and I want to find it's tab if how can I achiever that ?



Title: Re: Finding the parent Tab of an element
Post by: devnull on March 25, 2015, 07:55:42 PM
I am trying to select the parent TAB of a REQUIRED input which failed validation and then show the "This field is Required" message for that field.

The following code successfully gets the tab object, selects the tab of the field, but I cannot seem to get the "This filed is required" message to show next to the input after enabling the tab ?

I have tried inv.prev('input').textbox('validate'); but that does not appear to work ?

Code:
    function eltaben(inv){
      var tab = $(inv).closest('.tabs-panels');
      var tob = tab.parent('.tabs-container');
      tab.children('.panel').each(function(){
        var me = $(this);
        if(me.find(inv).length > 0) {
          tob.tabs('select',me.index());
        }
      })      
    }
    var vali = me.form('validate');
    if(!vali) {
      var vis = $(this).find('.textbox-invalid:visible').first();
      if(vis.length ==0) {
        var inv = $(this).find('.textbox-invalid:hidden');
        eltaben(inv);
        inv.prev('input').textbox('validate');
      }


Title: Re: Select the parent tab of a required input & show validation message
Post by: stworthy on March 26, 2015, 04:01:31 AM
Please notice this statement.
var vali = me.form('validate');

The 'me' is a <DIV> object, you need to get the 'form' object before calling the 'validate' method, please try to use the code below instead.
var vali = me.find('form').form('validate');


Title: Re: Select the parent tab of a required input & show validation message
Post by: devnull on March 26, 2015, 04:26:18 AM
Sorry, you misunderstand the question.

I have now solved most of the problems, the only problem remaining now is how do I trigger the "This Field is required" on a specific input.

Form validate will always goto the first element that failed validation, but in this case the element is hidden in an unselected tab.

All I need to know now is how can I trigger the "This Filed is Required" programatically after I enable the tab and show the hidden input.

Thanks