2016-06-23 5 views
0

剣道要素と他のHTML要素を使用してリセットフォーム用の作成関数が必要です。私はこの関数を作成します:剣道要素と他のHTML要素を使用してリセットフォーム用の関数を作成する方法

function resetForm() { 
    var formName = $(this).data("form"); 
    var form = $(formName); 
    if (form) { 

    //orginal reset 
    form.trigger("reset"); 

    //custom reset 
    $(formName + " input").each(function() { 
     var cb = $(this).data("kendoDropDownList"); 
     if (cb) { 
     cb.value(""); 
     cb.text(""); 
     } 
    }); 


    } 
} 

正しく動作しません!

+0

正確に動作していないですか? http://dojo.telerik.com/@Stephen/IqAVE –

+0

私はすべての剣道のエレメットをフォームにリセットする必要があります –

答えて

0

私はこの方法を見つけた:

if (form) { 

    //custom reset 
    $(formName + " input[data-role='dropdownlist']").each(function() { 
     var item = $(this).data("kendoDropDownList"); 
     if (item && $(this).attr('id') != 'AgeType' && $(this).attr('id') != 'AllAnyType') { 
      item.value(""); 
      item.text(""); 
     } 
    }); 

    $(formName + " input.k-textbox").each(function() { 
     $(this).val(""); 
    }); 

    $(formName + " input[data-role='numerictextbox']").not("#TopNumber").each(function() { 
     var item = $(this).data("kendoNumericTextBox"); 
     if (item) { 
      item.value(""); 
     } 
    }); 

    $(formName + " textarea").each(function() { 
     $(this).val(""); 
    }); 

    $(formName + " :checkbox").each(function() { 
     this.checked = !this.checked; 
    }); 


    $(formName + " input[type=text]").each(function() { 
     $(this).val(""); 
    }); 
} 
関連する問題