SkyoceanHome
Home
Privacy
ダウンロード
SkyShop
Updated Information
チュートリアルコード集
References
記事編集
日付
ジャンルのカテゴリ―名
名前を選択して下さい。
Contexts
Controllers
Databases
Htmls
JavaScripts
Models
MVCTutorials
Others
Styles
Views
タイトル
内容の要旨
<p style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: 4px; padding: revert; -webkit-line-clamp: revert; color: rgba(0, 0, 0, 0.8); font-family: roboto, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;" data-pasted="true">以下は、前回のコードをさらに改良した <strong style="font-weight: 700;">ASP.NET Core MVC + jQuery + SweetAlert2</strong> 実装例です。<br>今回の変更点は以下の通りです。</p><ul style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: revert; padding: revert; color: rgba(0, 0, 0, 0.8); font-family: roboto, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><li style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin-top: revert; margin-right: revert; margin-bottom: 8px; margin-left: revert; padding: revert;"><strong style="font-weight: 700;">重複チェック機能</strong>を追加(既存カテゴリ名と同じ場合は保存しない)</li><li style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin-top: revert; margin-right: revert; margin-bottom: 8px; margin-left: revert; padding: revert;">SweetAlert2 の <strong style="font-weight: 700;">ローディング表示</strong>を追加(保存中や一覧再取得中にユーザー操作を防止)</li><li style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin-top: revert; margin-right: revert; margin-bottom: 8px; margin-left: revert; padding: revert;">コード構造を整理し、関数化で可読性向上</li></ul><pre data-priority="2" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(245, 245, 245); border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 8px; overflow: hidden; color: rgba(0, 0, 0, 0.8); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div data-bm="77" style="display: flex; height: 28px; flex-direction: row; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid rgba(0, 0, 0, 0.1); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(248, 244, 241);"><h5 style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: 0px; padding: revert; font-style: normal !important; font-variant: normal !important; font-weight: 400 !important; font-stretch: 100% !important; line-height: 18px; font-family: roboto, helvetica, sans-serif !important; font-optical-sizing: auto !important; font-size-adjust: none !important; font-kerning: auto !important; font-feature-settings: normal !important; font-variation-settings: normal !important; font-language-override: normal !important; font-size: 16px; display: inline-block; color: rgb(60, 81, 180);">Html</h5><div style="height: 28px;"><button type="button" tabindex="" title="Copy code" style="box-sizing: border-box; margin: 0px; padding: 0px; font: 400 13px / 20px roboto, helvetica, sans-serif; background-color: rgb(217, 223, 251); border: 1px solid rgba(0, 0, 0, 0); display: grid; grid-auto-flow: column; align-items: center; cursor: pointer; color: rgb(60, 81, 180) !important; text-decoration: none !important; border-radius: 9999px; block-size: 28px; gap: 2px; padding-inline: 10px;"><div style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; white-space: nowrap; text-overflow: ellipsis; overflow: clip; max-block-size: calc(1lh); padding-inline: 2px;">Copy code</div></button></div></div><code style="border-radius: 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255); display: block; white-space: pre-wrap; overflow-wrap: anywhere; padding: 8px 16px 16px;"><span style="color: rgb(106, 115, 125);"><!-- CreateView の一部 --></span> <<span style="color: rgb(34, 134, 58);">select</span> <span style="color: rgb(0, 92, 197);">asp-for</span>=<span style="color: rgb(3, 47, 98);">"IncomeCategoryId"</span> <span style="color: rgb(0, 92, 197);">class</span>=<span style="color: rgb(3, 47, 98);">"form-control"</span> <span style="color: rgb(0, 92, 197);">id</span>=<span style="color: rgb(3, 47, 98);">"IncomeCategoryId"</span> <span style="color: rgb(0, 92, 197);">asp-items</span>=<span style="color: rgb(3, 47, 98);">"@(ViewData["</span><span style="color: rgb(0, 92, 197);">IncomeCategoryId</span>"] <span style="color: rgb(0, 92, 197);">as</span> <span style="color: rgb(0, 92, 197);">SelectList</span>)"> <<span style="color: rgb(34, 134, 58);">option</span> <span style="color: rgb(0, 92, 197);">value</span>=<span style="color: rgb(3, 47, 98);">"add"</span>>+ 項目を追加</<span style="color: rgb(34, 134, 58);">option</span>> </<span style="color: rgb(34, 134, 58);">select</span>> <span style="color: rgb(106, 115, 125);"><!-- SweetAlert2 CDN --></span> <<span style="color: rgb(34, 134, 58);">script</span> <span style="color: rgb(0, 92, 197);">src</span>=<span style="color: rgb(3, 47, 98);">"https://cdn.jsdelivr.net/npm/sweetalert2@11"</span>></<span style="color: rgb(34, 134, 58);">script</span>> <span style="color: rgb(106, 115, 125);"><!-- jQuery CDN --></span> <<span style="color: rgb(34, 134, 58);">script</span> <span style="color: rgb(0, 92, 197);">src</span>=<span style="color: rgb(3, 47, 98);">"https://code.jquery.com/jquery-3.6.0.min.js"</span>></<span style="color: rgb(34, 134, 58);">script</span>> <<span style="color: rgb(34, 134, 58);">script</span>> $(<span style="color: rgb(215, 58, 73);">function</span> () { <span style="color: rgb(215, 58, 73);">const</span> $select = $(<span style="color: rgb(3, 47, 98);">"#IncomeCategoryId"</span>); $select.<span style="color: rgb(111, 66, 193);">on</span>(<span style="color: rgb(3, 47, 98);">"change"</span>, <span style="color: rgb(215, 58, 73);">function</span> () { <span style="color: rgb(215, 58, 73);">if</span> ($(<span style="color: rgb(215, 58, 73);">this</span>).<span style="color: rgb(111, 66, 193);">val</span>() === <span style="color: rgb(3, 47, 98);">"add"</span>) { <span style="color: rgb(111, 66, 193);">openAddCategoryDialog</span>(); } }); <span style="color: rgb(215, 58, 73);">function</span> <span style="color: rgb(111, 66, 193);">openAddCategoryDialog</span>() { <span style="color: rgb(111, 66, 193);">Swal</span>.<span style="color: rgb(111, 66, 193);">fire</span>({ <span style="color: rgb(0, 92, 197);">title</span>: <span style="color: rgb(3, 47, 98);">'新しい項目を追加'</span>, <span style="color: rgb(0, 92, 197);">text</span>: <span style="color: rgb(3, 47, 98);">'追加するカテゴリ名を入力してください'</span>, <span style="color: rgb(0, 92, 197);">input</span>: <span style="color: rgb(3, 47, 98);">'text'</span>, <span style="color: rgb(0, 92, 197);">inputPlaceholder</span>: <span style="color: rgb(3, 47, 98);">'例: 家賃, 光熱費'</span>, <span style="color: rgb(0, 92, 197);">icon</span>: <span style="color: rgb(3, 47, 98);">'question'</span>, <span style="color: rgb(0, 92, 197);">showCancelButton</span>: <span style="color: rgb(0, 92, 197);">true</span>, <span style="color: rgb(0, 92, 197);">confirmButtonText</span>: <span style="color: rgb(3, 47, 98);">'保存'</span>, <span style="color: rgb(0, 92, 197);">cancelButtonText</span>: <span style="color: rgb(3, 47, 98);">'キャンセル'</span>, <span style="color: rgb(0, 92, 197);">inputAttributes</span>: { <span style="color: rgb(0, 92, 197);">autofocus</span>: <span style="color: rgb(3, 47, 98);">'autofocus'</span> }, <span style="color: rgb(0, 92, 197);">inputValidator</span>: (value) => { <span style="color: rgb(215, 58, 73);">if</span> (!value || !value.<span style="color: rgb(111, 66, 193);">trim</span>()) { <span style="color: rgb(215, 58, 73);">return</span> <span style="color: rgb(3, 47, 98);">'カテゴリ名は必須です'</span>; } } }).<span style="color: rgb(111, 66, 193);">then</span>((result) => { <span style="color: rgb(215, 58, 73);">if</span> (result.isConfirmed) { <span style="color: rgb(215, 58, 73);">let</span> newCategoryName = result.value.<span style="color: rgb(111, 66, 193);">trim</span>(); <span style="color: rgb(111, 66, 193);">checkDuplicateAndSave</span>(newCategoryName); } <span style="color: rgb(215, 58, 73);">else</span> { $select.<span style="color: rgb(111, 66, 193);">val</span>(<span style="color: rgb(3, 47, 98);">""</span>); } }); } <span style="color: rgb(215, 58, 73);">function</span> <span style="color: rgb(111, 66, 193);">checkDuplicateAndSave</span>(name) { <span style="color: rgb(111, 66, 193);">Swal</span>.<span style="color: rgb(111, 66, 193);">showLoading</span>(); $.<span style="color: rgb(111, 66, 193);">getJSON</span>(<span style="color: rgb(3, 47, 98);">'/IncomeCategory/Exists'</span>, { <span style="color: rgb(0, 92, 197);">name</span>: name }, <span style="color: rgb(215, 58, 73);">function</span> (exists) { <span style="color: rgb(215, 58, 73);">if</span> (exists) { <span style="color: rgb(111, 66, 193);">Swal</span>.<span style="color: rgb(111, 66, 193);">fire</span>(<span style="color: rgb(3, 47, 98);">'重複エラー'</span>, <span style="color: rgb(3, 47, 98);">'同じカテゴリ名が既に存在します'</span>, <span style="color: rgb(3, 47, 98);">'warning'</span>); $select.<span style="color: rgb(111, 66, 193);">val</span>(<span style="color: rgb(3, 47, 98);">""</span>); } <span style="color: rgb(215, 58, 73);">else</span> { <span style="color: rgb(111, 66, 193);">saveCategory</span>(name); } }).<span style="color: rgb(111, 66, 193);">fail</span>(<span style="color: rgb(215, 58, 73);">function</span> () { <span style="color: rgb(111, 66, 193);">Swal</span>.<span style="color: rgb(111, 66, 193);">fire</span>(<span style="color: rgb(3, 47, 98);">'通信エラー'</span>, <span style="color: rgb(3, 47, 98);">'重複チェックに失敗しました'</span>, <span style="color: rgb(3, 47, 98);">'error'</span>); $select.<span style="color: rgb(111, 66, 193);">val</span>(<span style="color: rgb(3, 47, 98);">""</span>); }); } <span style="color: rgb(215, 58, 73);">function</span> <span style="color: rgb(111, 66, 193);">saveCategory</span>(name) { <span style="color: rgb(111, 66, 193);">Swal</span>.<span style="color: rgb(111, 66, 193);">showLoading</span>(); $.<span style="color: rgb(111, 66, 193);">ajax</span>({ <span style="color: rgb(0, 92, 197);">url</span>: <span style="color: rgb(3, 47, 98);">'/IncomeCategory/CreateAjax'</span>, <span style="color: rgb(0, 92, 197);">type</span>: <span style="color: rgb(3, 47, 98);">'POST'</span>, <span style="color: rgb(0, 92, 197);">data</span>: { <span style="color: rgb(0, 92, 197);">name</span>: name }, <span style="color: rgb(0, 92, 197);">success</span>: <span style="color: rgb(215, 58, 73);">function</span> (response) { <span style="color: rgb(215, 58, 73);">if</span> (response.success) { <span style="color: rgb(111, 66, 193);">refreshCategoryList</span>(response.id); <span style="color: rgb(111, 66, 193);">Swal</span>.<span style="color: rgb(111, 66, 193);">fire</span>(<span style="color: rgb(3, 47, 98);">'保存しました'</span>, <span style="color: rgb(3, 47, 98);">''</span>, <span style="color: rgb(3, 47, 98);">'success'</span>); } <span style="color: rgb(215, 58, 73);">else</span> { <span style="color: rgb(111, 66, 193);">Swal</span>.<span style="color: rgb(111, 66, 193);">fire</span>(<span style="color: rgb(3, 47, 98);">'エラー'</span>, response.message || <span style="color: rgb(3, 47, 98);">'保存に失敗しました'</span>, <span style="color: rgb(3, 47, 98);">'error'</span>); $select.<span style="color: rgb(111, 66, 193);">val</span>(<span style="color: rgb(3, 47, 98);">""</span>); } }, <span style="color: rgb(0, 92, 197);">error</span>: <span style="color: rgb(215, 58, 73);">function</span> (xhr) { <span style="color: rgb(111, 66, 193);">Swal</span>.<span style="color: rgb(111, 66, 193);">fire</span>(<span style="color: rgb(3, 47, 98);">'通信エラー'</span>, <span style="color: rgb(3, 47, 98);">`ステータス: <span style="color: rgb(36, 41, 46);">${xhr.status}</span>`</span>, <span style="color: rgb(3, 47, 98);">'error'</span>); $select.<span style="color: rgb(111, 66, 193);">val</span>(<span style="color: rgb(3, 47, 98);">""</span>); } }); } <span style="color: rgb(215, 58, 73);">function</span> <span style="color: rgb(111, 66, 193);">refreshCategoryList</span>(selectedId) { <span style="color: rgb(111, 66, 193);">Swal</span>.<span style="color: rgb(111, 66, 193);">showLoading</span>(); $.<span style="color: rgb(111, 66, 193);">getJSON</span>(<span style="color: rgb(3, 47, 98);">'/IncomeCategory/GetAll'</span>, <span style="color: rgb(215, 58, 73);">function</span> (data) { $select.<span style="color: rgb(111, 66, 193);">empty</span>(); $.<span style="color: rgb(111, 66, 193);">each</span>(data, <span style="color: rgb(215, 58, 73);">function</span> (i, item) { $select.<span style="color: rgb(111, 66, 193);">append</span>($(<span style="color: rgb(3, 47, 98);">"<option>"</span>, { <span style="color: rgb(0, 92, 197);">value</span>: item.id, <span style="color: rgb(0, 92, 197);">text</span>: item.name })); }); $select.<span style="color: rgb(111, 66, 193);">append</span>($(<span style="color: rgb(3, 47, 98);">"<option>"</span>, { <span style="color: rgb(0, 92, 197);">value</span>: <span style="color: rgb(3, 47, 98);">"add"</span>, <span style="color: rgb(0, 92, 197);">text</span>: <span style="color: rgb(3, 47, 98);">"+ 項目を追加"</span> })); <span style="color: rgb(215, 58, 73);">if</span> (selectedId) { $select.<span style="color: rgb(111, 66, 193);">val</span>(selectedId); } }).<span style="color: rgb(111, 66, 193);">fail</span>(<span style="color: rgb(215, 58, 73);">function</span> () { <span style="color: rgb(111, 66, 193);">Swal</span>.<span style="color: rgb(111, 66, 193);">fire</span>(<span style="color: rgb(3, 47, 98);">'通信エラー'</span>, <span style="color: rgb(3, 47, 98);">'カテゴリ一覧の取得に失敗しました'</span>, <span style="color: rgb(3, 47, 98);">'error'</span>); }); } }); </<span style="color: rgb(34, 134, 58);">script</span>> </code></pre><h3 style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: revert; padding: revert; display: inline-block; font: 400 20px / 22px roboto, helvetica, sans-serif; color: rgba(0, 0, 0, 0.8); letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">サーバー側(ASP.NET Core MVC)例</h3><pre data-priority="2" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(245, 245, 245); border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 8px; overflow: hidden; color: rgba(0, 0, 0, 0.8); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div data-bm="78" style="display: flex; height: 28px; flex-direction: row; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid rgba(0, 0, 0, 0.1); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(248, 244, 241);"><h5 style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: 0px; padding: revert; font-style: normal !important; font-variant: normal !important; font-weight: 400 !important; font-stretch: 100% !important; line-height: 18px; font-family: roboto, helvetica, sans-serif !important; font-optical-sizing: auto !important; font-size-adjust: none !important; font-kerning: auto !important; font-feature-settings: normal !important; font-variation-settings: normal !important; font-language-override: normal !important; font-size: 16px; display: inline-block; color: rgb(60, 81, 180);">Csharp</h5><div style="height: 28px;"><button type="button" tabindex="" title="Copy code" style="box-sizing: border-box; margin: 0px; padding: 0px; font: 400 13px / 20px roboto, helvetica, sans-serif; background-color: rgb(217, 223, 251); border: 1px solid rgba(0, 0, 0, 0); display: grid; grid-auto-flow: column; align-items: center; cursor: pointer; color: rgb(60, 81, 180) !important; text-decoration: none !important; border-radius: 9999px; block-size: 28px; gap: 2px; padding-inline: 10px;"><div style="box-sizing: border-box; margin: 0px; padding: 0px; min-inline-size: 0px; max-inline-size: 100%; white-space: nowrap; text-overflow: ellipsis; overflow: clip; max-block-size: calc(1lh); padding-inline: 2px;">Copy code</div></button></div></div><code style="border-radius: 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255); display: block; white-space: pre-wrap; overflow-wrap: anywhere; padding: 8px 16px 16px;">[<span style="color: rgb(0, 92, 197);">HttpGet</span>] <span style="color: rgb(215, 58, 73);">public</span> IActionResult <span style="color: rgb(111, 66, 193);">Exists</span>(<span style="color: rgb(227, 98, 9);">string</span> name) { <span style="color: rgb(227, 98, 9);">bool</span> exists = _context.IncomeCategories .Any(c => c.Name.Trim() == name.Trim()); <span style="color: rgb(215, 58, 73);">return</span> Json(exists); } [<span style="color: rgb(0, 92, 197);">HttpPost</span>] <span style="color: rgb(215, 58, 73);">public</span> IActionResult <span style="color: rgb(111, 66, 193);">CreateAjax</span>(<span style="color: rgb(227, 98, 9);">string</span> name) { <span style="color: rgb(215, 58, 73);">if</span> (<span style="color: rgb(227, 98, 9);">string</span>.IsNullOrWhiteSpace(name)) { <span style="color: rgb(215, 58, 73);">return</span> Json(<span style="color: rgb(215, 58, 73);">new</span> { success = <span style="color: rgb(0, 92, 197);">false</span>, message = <span style="color: rgb(3, 47, 98);">"カテゴリ名は必須です。"</span> }); } <span style="color: rgb(215, 58, 73);">var</span> category = <span style="color: rgb(215, 58, 73);">new</span> IncomeCategory { Name = name.Trim() }; _context.IncomeCategories.Add(category); _context.SaveChanges(); <span style="color: rgb(215, 58, 73);">return</span> Json(<span style="color: rgb(215, 58, 73);">new</span> { success = <span style="color: rgb(0, 92, 197);">true</span>, id = category.Id, name = category.Name }); } [<span style="color: rgb(0, 92, 197);">HttpGet</span>] <span style="color: rgb(215, 58, 73);">public</span> IActionResult <span style="color: rgb(111, 66, 193);">GetAll</span>() { <span style="color: rgb(215, 58, 73);">var</span> list = _context.IncomeCategories .Select(c => <span style="color: rgb(215, 58, 73);">new</span> { id = c.Id, name = c.Name }) .ToList(); <span style="color: rgb(215, 58, 73);">return</span> Json(list); } </code></pre><h3 style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: revert; padding: revert; display: inline-block; font: 400 20px / 22px roboto, helvetica, sans-serif; color: rgba(0, 0, 0, 0.8); letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">改良ポイント</h3><ol style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: revert; padding: revert; color: rgba(0, 0, 0, 0.8); font-family: roboto, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><li style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin-top: revert; margin-right: revert; margin-bottom: 8px; margin-left: revert; padding: revert;"><strong style="font-weight: 700;">重複チェック</strong> (<code style="border-radius: 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255);">/IncomeCategory/Exists</code>) を追加し、同名登録を防止。</li><li style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin-top: revert; margin-right: revert; margin-bottom: 8px; margin-left: revert; padding: revert;"><strong style="font-weight: 700;">SweetAlert2 のローディング表示</strong>で保存中や取得中の操作を防止。</li><li style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin-top: revert; margin-right: revert; margin-bottom: 8px; margin-left: revert; padding: revert;"><strong style="font-weight: 700;">関数分割</strong>で可読性・保守性を向上。</li></ol><p style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: 4px; padding: revert; -webkit-line-clamp: revert; color: rgba(0, 0, 0, 0.8); font-family: roboto, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">この形なら、<br>「+ 項目を追加」→ モーダル入力 → 重複チェック → 保存 → 最新一覧反映<br>という流れが安全かつ安定して動作します。</p><p style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: 4px; padding: revert; -webkit-line-clamp: revert; color: rgba(0, 0, 0, 0.8); font-family: roboto, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">もし希望があれば、このコードを <strong style="font-weight: 700;">カテゴリ名の部分一致検索付きオートコンプリート</strong> に拡張して、入力時に候補を表示することも可能です。<br>そうすれば既存カテゴリの再利用がさらに簡単になります。</p><p style="border: 0px; border-collapse: collapse; border-spacing: 0px; list-style-position: initial; list-style-image: initial; list-style-type: revert; margin: 4px; padding: revert; -webkit-line-clamp: revert; color: rgba(0, 0, 0, 0.8); font-family: roboto, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">このオートコンプリート版も作りますか?</p><p data-f-id="pbf" style="text-align: center; font-size: 14px; margin-top: 30px; opacity: 0.65; font-family: sans-serif;">Powered by <a href="https://www.froala.com/wysiwyg-editor?pb=1" title="Froala Editor">Froala Editor</a></p>
コピーする
添付画像
画像を変更
Back to List
//検索文:Editor内でHTMLコードをコピーさせる