わからないこと
いつもお世話になっております。
この度JqueryUIDialogを用い、ajaxでダイアログ内のviewを出力しようとしています。
しかし、おそらくajaxが原因で、ダイアログを一度閉じ、再び開こうとするとエラーが出ます。
エラー
「Uncaught TypeError: $(...).dialog is not a function」
目的は、エラーを解消し、ajax実行時にダイアログ内を表示させ、かつデータを飛ばすことにあります。
ご教授いただければ幸いです。
###コード
html
1<label style="padding-top: 10px; margin-bottom: 10px;" id="open-cv-dialog" class="bt-photo01 ui-bt-nomal ui-opaimg"> 2写真 3</label> 4<div class="dialog" id="addImagesDialog" style="overflow: hidden;display: none; outline: 0px; height: auto;" data-dialog="true"> 5 @include('portal.cv-upload-dialog') 6 </div> 7 8<script type="text/javascript" src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script> 9 <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"> 10<script type="text/javascript" language="javascript"> 11 12
portal.cv-upload-dialog(blade)
<div class="dialog-content"> </div> <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script> $(function() { $("#open-cv-dialog").on("click", function(){ $("#addImagesDialog").dialog({ title: "登録", width: 372, modal: true, buttons: [ { text: '送付する', id: 'yes-sending', click: function() { $(this).dialog('close'); } }, { text: 'キャンセル', id: 'no-sending', click: function() { $(this).dialog('close'); $.ajax({ url: "{{action('PortalController@cancelImage')}}", type: 'post', dataType: 'html', // data: fd, // processData: false, // contentType: false }) } } ], open: function() { imgDialogContent(); } }) <?// ダイアログの表示位置をオプションで修正しても変更できなかったので、力技で変更?> $("#addImagesDialog").parent("div.ui-widget").css('top','98px'); }); // ダイアログ内読み込み function imgDialogContent(){ $.ajax({ type : "POST", url : "{{action('PortalController@ajaximg')}}", data: { 'book': 'cv', 'id': "{!!$input['id']!!}" }, dataType: "html", success : function(re) { $("#addImagesDialog").html(re); }, error : function() { alert('失敗しました。'); } }); } }); </script>
php
1public function ajaximg() { 2 3return view('portal.cv-upload-dialog'); 4 }
※laravelのバージョンは5.1です。
何卒よろしくお願い申し上げます。


回答1件
あなたの回答
tips
プレビュー