{"id":179211,"date":"2013-05-10T09:51:02","date_gmt":"2013-05-10T05:51:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=179211"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=179211","title":{"rendered":"<span class=\"post_title\">\u041c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u043d\u043e bootstrap \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0412\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d bootstrap-modal.js \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u044b. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u043d\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u0441 \u0432\u0430\u043c\u0438 \u0441\u0432\u043e\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c, \u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u044f\u0449\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u0437\u0434\u043e\u0440\u043e\u0432\u0430\u044f \u043a\u0440\u0438\u0442\u0438\u043a\u0430 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p>  \u0418\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441 \u0444\u043e\u0440\u043c\u043e\u0439 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u043e\u0432\u0430\u0440\u0430. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430 \u0444\u043e\u0440\u043c\u0443 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u043f\u0435\u0440\u0435\u0447\u043d\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439. \u0420\u044f\u0434\u043e\u043c \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u043e\u0432\u0441\u043a\u0443\u044e \u0438\u043a\u043e\u043d\u043a\u0443 icon-plus-sing, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u043c \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c57\/935\/0f8\/c579350f80ab2fe3e9d2959134dd20ad.png\" alt=\"image\"\/><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<pre><code class=\"html\">&lt;div id=&quot;edit_producer&quot; class=&quot;modal fade hide in&quot;&gt; &lt;\/div&gt;  &lt;div class=&quot;editor-label&quot;&gt;     @Html.LabelFor(model =&gt; model.Producers) &lt;\/div&gt; &lt;div class=&quot;editor-field&quot;&gt;     @Html.DropDownListFor(model =&gt; model.ProducerId, Model.Producers)     @Ajax.RawActionLink(                         &quot;&lt;i class='icon-plus-sign icon-2x'&gt;&lt;\/i&gt;&quot;,                         ActionConstants.Edit,                         ProducerController.Name,                         null,                         new AjaxOptions                             {                                 UpdateTargetId = &quot;edit_producer&quot;,                                 InsertionMode = InsertionMode.Replace,                                 HttpMethod = &quot;GET&quot;,                                 OnSuccess = &quot;ShowProducerEditModal&quot;                             },                         null)      @Html.ValidationMessageFor(model =&gt; model.Producers) &lt;\/div&gt; &lt;\/div&gt; <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f <a href=\"http:\/\/develoq.net\/2011\/how-to-create-custom-html-helpers-for-asp-net-mvc-3-and-razor-view-engine\/\">\u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 html-\u0445\u0435\u043b\u043f\u0435\u0440\u044b<\/a> DropDownListFor \u0438 RawActionLink.<\/p>\n<p>  \u0418\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435. \u041f\u0438\u0448\u0435\u043c js \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 OnSuccess.<\/p>\n<pre><code class=\"javascript\">function ShowProducerEditModal() {      $('#edit_producer').modal('show');  } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u044d\u043a\u0448\u0435\u043d \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 ProducerController \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430.<\/p>\n<pre><code class=\"cs\">[HttpGet] public ActionResult Edit(long? id) {     ProducerEditModel model = service.GetProducerEditModel(id);     return PartialView(&quot;ProducerEditPartial&quot;, model); } <\/code><\/pre>\n<p>  \u0427\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430:  <\/p>\n<pre><code class=\"html\">@using (Ajax.BeginForm(                 ActionConstants.Edit,                 ProducerController.Name,                 new AjaxOptions                     {                         HttpMethod = &quot;POST&quot;,                         OnSuccess = &quot;OnSuccess&quot;                     })) {     &lt;div class=&quot;modal-header&quot;&gt;         &lt;a class=&quot;close&quot; data-dismiss=&quot;modal&quot;&gt;\u00d7&lt;\/a&gt;         &lt;h3&gt;\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f&lt;\/h3&gt;     &lt;\/div&gt;     &lt;div class=&quot;modal-body&quot;&gt;         @Html.HiddenFor(model =&gt; model.Id)          &lt;div class=&quot;editor-label&quot;&gt;             @Html.LabelFor(model =&gt; model.Name)         &lt;\/div&gt;         &lt;div class=&quot;editor-field&quot;&gt;             @Html.EditorFor(model =&gt; model.Name)             @Html.ValidationMessageFor(model =&gt; model.Name)         &lt;\/div&gt;     &lt;\/div&gt;     &lt;div class=&quot;modal-footer&quot;&gt;         &lt;input type=&quot;submit&quot; class=&quot;btn btn-success&quot; value=&quot;\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&quot; \/&gt;         &lt;a href=&quot;#&quot; class=&quot;btn&quot; data-dismiss=&quot;modal&quot;&gt;Close&lt;\/a&gt;     &lt;\/div&gt; } <\/code><\/pre>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u043f\u043e\u043f\u0430\u043f \u0441 \u0444\u043e\u0440\u043c\u043e\u0439 \u043f\u043e \u043a\u043b\u0438\u043a\u0443 \u043d\u0430 \u0442\u0440\u0438\u0433\u0433\u0435\u0440.<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/34e\/b7c\/724\/34eb7c7244c7f91ed88ffb61ccb7b36c.png\" alt=\"image\"\/><\/p>\n<p>  \u0421\u043b\u0435\u0434\u043e\u043c \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0438\u0448\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044f OnSuccess. \u041f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430. \u0415\u0441\u043b\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u043e\u0440\u043c\u044b \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c, \u0442\u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u0443 \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430 \u0435\u0449\u0451 \u0440\u0430\u0437.  <\/p>\n<pre><code class=\"javascript\">function OnSuccess(data) {     if (data.isValid) {         $('#edit_producer').modal('hide');         if (data.isNew) {             AppendToDropDownList(data.name, data.id, 'ProducerId');         } else {             EditDropDownListItem(data.name, data.id, 'ProducerId');         }     } else {         $('#edit_producer').html(data.partialView);     } }  function AppendToDropDownList(text, value, ddlId) {     var newItem = $('&lt;option\/&gt;', {         value: value,         text: text     });      $('#' + ddlId).append(newItem); }  function EditDropDownListItem(text, value, ddlId) {     $('#' + ddlId + ' option[value=&quot;' + value + '&quot;]').text(text).val(value); } <\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 ProducerController \u043f\u0438\u0448\u0435\u043c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u044d\u043a\u0448\u0435\u043d.<br \/>  \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 RenderRazorViewToString  <\/p>\n<pre><code class=\"cs\">[HttpPost] public ActionResult Edit(ProducerEditModel model) {     if (ModelState.IsValid)     {         bool isNew = model.Id == 0;         long id = service.Save(model);         return Json(new             {                 isValid = true,                 id = id,                 name = model.Name,                 isNew = isNew             });     }      return Json(new     {         partialView = RenderUtils.RenderRazorViewToString(this, &quot;ProducerEditPartial&quot;, model),         isValid = false     }); } <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/3b5\/ef2\/332\/3b5ef23321b296a8bc34b023e7d8de61.png\" alt=\"image\"\/><\/p>\n<p>  \u0412 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<p>  \u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438:<br \/>  <a href=\"http:\/\/bootstrap-ru.com\/\">\u0420\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e bootstrap<\/a><br \/>  <a href=\"http:\/\/www.w3resource.com\/twitter-bootstrap\/modals-tutorial.php\">\u0422\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043f\u043e bootstrap-modal.js<\/a><br \/>  <a href=\"https:\/\/github.com\/jschr\/bootstrap-modal\">\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 bootstrap-modal.js<\/a> \t\t\t \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/179211\/\"> http:\/\/habrahabr.ru\/post\/179211\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0412\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d bootstrap-modal.js \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u044b. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u043d\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u0441 \u0432\u0430\u043c\u0438 \u0441\u0432\u043e\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c, \u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u044f\u0449\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u0437\u0434\u043e\u0440\u043e\u0432\u0430\u044f \u043a\u0440\u0438\u0442\u0438\u043a\u0430 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p>  \u0418\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441 \u0444\u043e\u0440\u043c\u043e\u0439 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u043e\u0432\u0430\u0440\u0430. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430 \u0444\u043e\u0440\u043c\u0443 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u043f\u0435\u0440\u0435\u0447\u043d\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439. \u0420\u044f\u0434\u043e\u043c \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u043e\u0432\u0441\u043a\u0443\u044e \u0438\u043a\u043e\u043d\u043a\u0443 icon-plus-sing, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u043c \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c57\/935\/0f8\/c579350f80ab2fe3e9d2959134dd20ad.png\" alt=\"image\"\/>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-179211","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/179211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=179211"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/179211\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=179211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=179211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=179211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}