Set button action in controller - extjs

I have a navigation view with one button in the toolbar. Based on the view pushed, the button's label and functionality should chang. I've managed to do this by creating many buttons and activating them as needed (hide/show)
Instead of doing that approach I'd like to have just one button and in the controller change the text and action. Something along these lines:
this.getButton().setHtml("new text");
this.getButton().action = "newaction";
setHtml works, but setting the action doesn't. Examining the button in the console, I see the action changes but when I click it, it responds to the previous action.
Any suggestions on how to approach this?
Thanks

You should use setText instead of setHtml that, err... Doesn't seem to exist! And setHandler to change the handler function.
Alternatively, since you say that you're working in a controller, you can attach a function to the click event of the button and, inside this listener function, decide what action to execute in the current context.

Related

ADF TreeTable: Calling a method on click of expand button of master row

I need to call a method whenever expand button of master row in treetable, is clicked. How can i achieve it? I put image link in nodestamp , but method bind in its action listner is not getting fired.
You might try selectionlistener or rowdisclosurelistener instead. Check docs here.

Remove action event from component

In the GUI Designer I accidentally clicked on the Action Event button for a component I don't want to have a click event. Now I can't figure out how to get rid of it. Leaving the generated override method blank will prevent the click from triggering anything, but I don't even want the component (a List) to be clickable, just the list items themselves.
How do I do this?
Just delete the method from the state machine and save. It will remove it as if you never clicked that action event button.

How to trigger Angular-Strap modal with event other than click event?

Angular Strap V2's modal seems to have lost some functionality of V1, and I'm struggling to work out how to achieve what was fairly straightforward with V1 (using angular-strap's $modal service).
The documentation only shows an example where the modal is attached to a DOM element like a button and seems to be automatically wired to the click event. However I want to use other events eg SwipeLeft is a common convention for deleting something, but I'd like to pop up an "Are you sure?" modal prompt for this action. Is this possible?
Is there any way to use the V2 modal with any event other than the click event?
Looking at the source code, it looks like you can bind your own events, or use the default click event.
It should work if you add a data-trigger='myEvent' to your markup.
https://github.com/mgcrea/angular-strap/blob/master/src/modal/modal.js#L279

Backbone Event for VIEW doesn't trigger if we click on a link which has the HREF which is already there in the URL

I have a view where i have 3 links(routers which have methods triggering a View bound event).
Normally based on the link i click i reduce from the main collection a subset and render it in another VIEW.
But suppose i have clicked on a link say '....#/remaining' and then i click again on the same link, the event bound is not triggered.
But when i click on any other link and click back on the desired link, everything works!
Is this a Backbone feature/defect, if so what are the alternatives to work around this?
Thanks in Advance.
I think this is because you're doing the reduce in the Router. When you're already on #remaining, your route handler won't execute because there's no route change at all.
Instead of that, you could use a View UI event on the link to manipulate the collection, so it will always be called no matter if you're already on that route or not.
You could also use events as a communication method between your app's components: your data, your views, and so on.
Hope it helps, I didn't put any code because you didn't either. :)

Angular: How to click on modal button when user hits Enter?

I have several Angular UI Modals. Every modal has a Cancel button and an "Action" button (which can be Create, Delete, etc).
I use the ui-keyup directive from Angular UI to identify when user pressed buttons.
I would like to click the "Action" button when user hits Enter.
How could I achieve that?
Here is where I got to so far: http://plnkr.co/edit/n6dgiE?p=preview
http://plnkr.co/edit/icKazZ?p=preview
So, I just made sure that createIt() was available on the ui-event (by moving the controller up to <body>) and just triggered it directly.
Now lets say this isn't feasible (there are too many layers between the body tag and the createIt() function). What you COULD do is put some sort of global-handler function or service on $rootScope and then pass the triggering through. However communication down scopes, or across controllers is outside the explicit scope of this question :-)

Resources