Inquiridor
Incompatibilidade Jquery Mask com formulário Ajax

Pergunta
-
Olá amigos, hoje me deparei uma uma situação, tenho um partialview em ajax com alguns campos que possuem mascaras, quando dou submit deste formulário a minha classe fica nula, depois de alguns testes resolvi comentar o jquery das mascaras e o formulário foi submetido com sucesso.Existe alguma forma de possuir um formulário em Ajax e utilizar o JqueryMask ou algum plugin para mascaras ?
Segue abaixo minha página...
@model SW.Model.TelefoneInfo
@section scriptHeader{
<script src="@Url.Content("~/Scripts/jquery.maskedinput-1.3.min.js")" type="text/javascript"></script>
}
<script>
jQuery(function ($) {
$("#Ddd").mask("(99)");
$("#Numero").mask("9999-9999");
});
</script>
@using (Ajax.BeginForm("AdicionarTelefones","Empresa", new {idTelefone = Model.Id, info = Model}, new AjaxOptions() { HttpMethod = "Post", OnComplete = "nomedaFuncao", OnFailure = "", InsertionMode = InsertionMode.Replace, UpdateTargetId = "tabs-2" }))
{
@Html.HiddenFor(model => model.Id)
<div class="editor-label">
@Html.LabelFor(model => model.Tipo)
</div>
<div class="editor-field">
@Html.EnumDropDownListFor(model => model.Tipo)
@Html.ValidationMessageFor(model => model.Tipo)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Ddd)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Ddd)
@Html.ValidationMessageFor(model => model.Ddd)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Numero)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Numero)
@Html.ValidationMessageFor(model => model.Numero)
</div>
<input type="submit" value="Adicionar" />
}
Agradeço desde já
Todas as Respostas
-
-
-
Esse parametro que você está passando não serve pra passar os dados para o servidor mas sim para gerar o link para a action.
Se você quer passar os dados para o servidor, então crie inputs do tipo hidden contendo todos os dados do Model, ou use somente o id do Model.
http://www.linkedin.com/pub/murilo-kunze/44/191/455
-
-
Resolvi meu problema, que na verdade não era só esse, mas era também a validação no cliente. Depois de muito pesquisar, encontrei algumas informações sobre o UnobtrusiveJQuery ele só renderiza e faz as devidas validações/submit's em alguns tipos de campos. que são estes:
@Html.TextBoxFor
@Html.HiddenFor
@Html.DropDownListFor
@Html.CheckBoxFor
@Html.ListBoxFor
@Html.PasswordFor
@Html.RadioButtonFor
@Html.TextAreaFor
@Html.DisplayForNo meu caso estava utilizando o EditorFor
Maiores informações http://www.codeguru.com/csharp/article.php/c18595/Unobtrusive-jQuery-Validation-Using-MVC3-and-Razor.htm
Murilo, muito obrigado pela ajuda!
- @Html.DropDownListFor - A drop down list that allows the user to choose one option from a list of options.
- @Html.CheckBoxFor - A single checkbox option.
- @Html.ListBoxFor - A multi-select listbox bound to an array of options.
- @Html.PasswordFor - A password field.
- @Html.RadioButtonFor - A single radio button option.
- @Html.TextAreaFor - Multi-Line text area.
- @Html.DisplayFor - Generic display, will follow what is set in the UI Hints.
- @Html.TextBoxFor - Standard textbox.
- @Html.HiddenFor - A hidden field that stores a value but renders no visible UI element to the page.
- @Html.DropDownListFor - A drop down list that allows the user to choose one option from a list of options.
- @Html.CheckBoxFor - A single checkbox option.
- @Html.ListBoxFor - A multi-select listbox bound to an array of options.
- @Html.PasswordFor - A password field.
- @Html.RadioButtonFor - A single radio button option.
- @Html.TextAreaFor - Multi-Line text area.
- @Html.DisplayFor - Generic display, will follow what is set in the UI Hints.
- @Html.TextBoxFor - Standard textbox.
- @Html.HiddenFor - A hidden field that stores a value but renders no visible UI element to the page.
- @Html.DropDownListFor - A drop down list that allows the user to choose one option from a list of options.
- @Html.CheckBoxFor - A single checkbox option.
- @Html.ListBoxFor - A multi-select listbox bound to an array of options.
- @Html.PasswordFor - A password field.
- @Html.RadioButtonFor - A single radio button option.
- @Html.TextAreaFor - Multi-Line text area.
- @Html.DisplayFor - Generic display, will follow what is set in the UI Hints.