2017-03-08 12 views
0

は、私はこれにしたい:ユーザーが好みのボタンをクリックした場合、私は、ダイアログボックスを表示もう一度ダイアログを閉じることはできませんか?

「レポートは、お気に入りに追加」し、ユーザーは

「レポートは、お気に入りから削除私は、ダイアログボックスを作成したお気に入りボタン二回目をクリックした "

しかし、ダイアログボックスは同じIDを持ちます。

私のコードの次

   $scope.toogleReportToFavorites = function (item) { 
       if (!item.isInFavorites) { 
        item.isInFavorites = true; 
        RepService.AddToDefaultFavourites(item.ReportId, function (reportCat) { 
         if ($scope.showRemovedDialog) { 
          $("#denemePicker").dialog("close"); //its works only first time 
          $scope.showAddedDialog = false; 
         } 
         else { 
          $scope.showAddedDialog = true; 
         } 
         WarningDialogs("Report added to favorites"); 
        }, function (ex) { 
         GlobalErrorHandler(ex); 
        }); 
       } else { 
        item.isInFavorites = false; 
        RepService.RemoveFromFavourites(item.ReportId, function() { 
         if ($scope.showAddedDialog) { 
          $("#denemePicker").dialog("close"); 
          $scope.showRemovedDialog = false; 
         } 
         else { 
          $scope.showRemovedDialog = true; 
         } 
         WarningDialogs("Report removed from favorites");  
        }, function (ex) { 
         GlobalErrorHandler(ex); 
        }); 
       } 
      }; 

と、これは私のWarningDialogs機能コードです:

function WarningDialogs(text, messageType, dialogWidth, callback, textAlign) { 
    if (textAlign == null || textAlign.length < 1) { 
     textAlign = 'center'; 
    } 
    $('<div>', { title: "deneme", id: 'denemePicker' }).html(text).css('text-align', textAlign).dialog(
      { 
       resizable: true, modal: true, closeOnEscape: true, width: dialogWidth, 
       create: function() { 
        isWarningDialogsShown = true; 
        $(this).css('maxHeight', '300px'); 
       }, 
       close: function (event, ui) { 
        isWarningDialogsShown = false; 
        if (callback) { 
         callback(); 
        } 
       }, 
       buttons: { 
        Close: function() { 
         $(this).dialog("close"); 
        } 
       } 
      }).css('overflow', 'auto'); 
    return; 
} 

私はいつもこのために仕事をしたい:$("#denemePicker").dialog("close");が、その唯一の仕事は初めて。私は理由が同じだと思う?

どうすればいいですか?

答えて

0

このコードは、あなた

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
<button type="button" class="btn btn-info" style="width:90%;" id="textChanger" status="1" onclick="counter;">D Box</button> 
 
<script> 
 
$(document).on('click','#textChanger',function(){ 
 
\t var status = $(this).attr('status'); 
 
\t if(status ==1){ 
 
\t \t $(this).attr('status',0); 
 
\t \t alert('Report added to favorites'); 
 
\t }else{ 
 
\t \t $(this).attr('status',1); 
 
\t \t alert('Report removed from favorites'); 
 
\t } 
 
}) 
 
     </script>

役立つかもしれません
関連する問題