0

So I have a button:

 <button type="button" ng-click="open('new_cm')" class="btn btn-primary" id="prideti">Add

Which calls a modal to open

I'm using AJAX to reload my html content(which contains that button) And button does not work after refreshing data. Maybe ng-click needs to be instillized somehow?

ajaxification:

<script>

    function ajaxifyGridMvc(gridContainerSelector, successCallback) {
        $(gridContainerSelector).on("click", ".grid-header a, .grid-pager li a",
            function (event) {
                var $grid_container = $(event.delegateTarget);
                var baseUrl = $grid_container.attr("data-source-url");
                var link = $(this).attr("href");
                $.get(baseUrl + link, function (data) {
                    if (data.Status <= 0) {
                        alert(data.Message);
                        return;
                    }
                    $grid_container.html(data);
                    if ($.isFunction(successCallback))
                        successCallback();
                });

                return false;
            });
    }

</script>

ajaxification on page load:

   <script>
        $(document).ready(function () {
            ajaxifyGridMvc("#mylists");
        });</script>

Changes are made here:

        <div id="mylists" data-source-url="@Url.Action("markemodelis")">
            @{Html.RenderAction("markemodelis");}
        </div>

Open() js:

  if (size == "new_cm") {
        modalInstance = $modal.open({

            templateUrl: '/Administration/CreateMM',
            controller: ModalInstanceCtrl,
            size: size,
            resolve: {
                items: function () {

                    return $scope.items;
                }
            }

        });
    }
tereško
  • 58,060
  • 25
  • 98
  • 150
user2614879
  • 151
  • 1
  • 2
  • 9

1 Answers1

0

Your problem is you are doing too much outside of angular. When you inject html with directives contained in it, angular doesn't know they exist.

You have to use $compile from within a directive to compile the directives with current scope context or they won't be recognized within angular.

Since all you have shown is jQuery and no html it is hard to tell you where to apply this directive.

You would be far better off getting rid of the jQuery and working within angular the way it is designed to work

See: How do I “think in AngularJS” if I have a jQuery background?

Community
  • 1
  • 1
charlietfl
  • 170,828
  • 13
  • 121
  • 150