Umbraco - Backoffice Extension - angular (how to refreh current window)
Hi Guys,
I have build a backoffice extension using angular and some ajax.
Basically there is a button that when clicked runs some ajax that calls my controller function. Some information is passed back if this was successful or not.
The controller function updates the current selected node and does some other stuff in the background. The problem the current node I am on when using my new context menu item does not refresh after running my code.
<div ng-controller="Umbraco.Editors.Content.approveMember">
<div class="umb-dialog-body form-horizontal">
<div class="umb-pane">
<h2>Approve Member</h2>
<div class="message-section"></div>
</div>
</div>
<div class="umb-dialog-footer btn-toolbar umb-btn-toolbar">
<a id="btnApprove" data-id="{{id}}" class="btn btn-primary">
Approve
</a>
<a class="btn btn-link" ng-click="nav.hideDialog()">
<localize key="general_cancel">Cancel</localize>
</a>
</div>
</div>
<script>
$("#btnApprove").click(function () {
var nodeId = $(this).attr("data-id");
$.ajax({
url: "/Umbraco/Backoffice/Api/Backend/ApproveMember?nodeId=" + nodeId,
type: 'GET',
success: function (data) {
$("#btnApprove").hide();
$(".message-section").html("<p><strong>The member was successfully approved.</strong></p>")
},
error: function (data) {
$("#btnApprove").hide();
$(".message-section").html("<p><strong>ERROR - The member could not be found. Please select the member and try again.</strong></p>")
}
});
});
</script>
I want to know if there is any way I can get the selected node to refresh one my ajax data is returned.
Or maybe even extending the close button to refresh the page when this is clicked or if the user clicks out of the context menu.
Thanks for your reply. Yeah this sort of does the trick. What I was trying to figure out how to do was only refresh the node window.
Since this action updating some properties on the node in view it would be great if I could just refresh the node screen. In much the same way the save and publish buttons does.
Why screen shot should demonstrate the screen I am trying to update. Following my approve click.
Umbraco - Backoffice Extension - angular (how to refreh current window)
Hi Guys,
I have build a backoffice extension using angular and some ajax.
Basically there is a button that when clicked runs some ajax that calls my controller function. Some information is passed back if this was successful or not.
The controller function updates the current selected node and does some other stuff in the background. The problem the current node I am on when using my new context menu item does not refresh after running my code.
I want to know if there is any way I can get the selected node to refresh one my ajax data is returned.
Or maybe even extending the close button to refresh the page when this is clicked or if the user clicks out of the context menu.
Thanks in advanced.
Kind Regards
David
Hi David
Are you looking for something like...
passing true should force the browser to reload rather than display from cache.
(injecting $window into your angular controller)
regards
Marc
Hi Marc,
Thanks for your reply. Yeah this sort of does the trick. What I was trying to figure out how to do was only refresh the node window.
Since this action updating some properties on the node in view it would be great if I could just refresh the node screen. In much the same way the save and publish buttons does.
Why screen shot should demonstrate the screen I am trying to update. Following my approve click.
Ahh I see
SaveAndPublish uses the method from the contenteditinghelperservice:
https://github.com/umbraco/Umbraco-CMS/blob/5397f2c53acbdeb0805e1fe39fda938f571d295a/src/Umbraco.Web.UI.Client/src/common/services/contenteditinghelper.service.js
details here:
https://our.umbraco.org/apidocs/ui/#/api/umbraco.services.contentEditingHelper
think you could just rebind the changed 'approved' property when you click approve, or trigger save and use handleSuccessfulSave?
regards
Marc
is working on a reply...