Send action from custom View in NSToolbarItem - cocoa

I created a Custom View as a Toolbar Item. Creating an action from the Toolbar item now doesn't work (it's not fired). Any ideas?

The action of an NSToolbarItem is only used if you leave the default view in place. Setting a custom view will mean that you need to setup any target/action/callbacks with that custom view instead: e.g. if you set a custom button or segmented control, you should set the target and action on that.

Related

Show bootstrap modal on server side validation

I have a ASP.Net Core MVC web application. I have a standard razor view which has a list of items with a delete button. What I want to do is if they user deletes an item from the grid go to the server calling an action which validates the item selected. IF invalid I want to return to the view and show a bootstrap modal explaining why the delete cannot be carried out. I call the delete routine using Controller / Action tag helpers and pass the unique Id to a controller event.
So basically if my delete validation fails show a modal dialog with a message. Any help please?
I ended up sorting this myself. Basically I set a viewbag property and give it a value of show. Then in my script section of my view I set the modal property to that viewbag.

Custom Modal in Create/Edit forms

I want to create a custom modal instead of the 'Element is created' at the bottom of the screen. How should I create a custom modal which says 'Element is created' and if it is a failure, mention the error.
You can supply another label using the translations or you can create a custom Admin Layout (use the layout prop) and replace the current Notification component.

How to add custom button to sidebar?

In my case I'm using server-side session (not authClient with token in cookies/local storage). So instead of using default LogoutButton I want to place custom button which will do simple "POST /logout" action. There are some examples in docs how to place custom buttons on resource pages, but nothing about sidebar. Any advices/examples?
A custom Sidebar is a custom Menu:
https://marmelab.com/admin-on-rest/AdminResource.html#menu ?

Removing view from subview does not call willRemoveSubview

I have a managing view controller that switches in one of a set of previously allocated sub view controllers when the user chooses a menu item.
When I switch in a view controller I hook up the view of the managing view controller to the view in the sub view controller.
[mvc.view addSubview:subvc.view];
It all seems to work fine.
However, when removing that sub view controller's view from the view hierarchy with (eg.. when switching pages in the application):
[subvc.view removeFromSuperview];
the willRemoveSubview method in the custom view class never fires. I've confirmed that when I make the removeFromSuperview call I am calling it on an instance of my custom view class.
Other methods in my custom view class do fire though, such as viewWillMoveToWindow.
The NSView reference doc says this method should be called?
Can anyone suggest why this isn't working?
I'm running on 10.8.2 compiling for 10.7 with Xcode 4.5.2
Thanks
Darren.
willRemoveSubview:, as the name suggests, is called on the super view, not the subview being removed.

How do I create a user control view in MVC3, create events and reuse it in other views?

I am new to MVC3. In asp.net user control, its fairly easy to create a user control that has a combo box with a button, with hover over event, and a collection property of combo box that then displays a list
how do i achieve this user control (partial view) in mvc3?
What you are looking for is helper methods. You can see a good explanation of it here. In that post, there is a great link for how to do this: Creating Custom HTML Helpers.
I am also a WebForms developer originally, and I had a hard time making the connection between user controls and HTML Helpers. This should give you enough guidance to get started with what you want.
Hover over event can be done using jQuery, your combo box just needs to have a CSS class in the partial view and then the even can be hooked up to that selector.
The Collection property will be inside the View Model that your partial view binds to.

Resources