I have multiple polymer components. Inside attached callback of each component, I perform variable initialization and function definition.
Based on a button click, I want to re-initialize variables of all components(inside attached callback) without restarting/refreshing.
Is it possible to call attached callback programmatically or using any events which don't reload the page?
How to call the attached callback programmatically event after the component is attached to DOM?
I haven't found a way to call the attached function in polymer, but as mentioned by #Kuba Simonovsky, we can use another function to call whenever wanted.
Related
I am trying to use a js library across my elements with the help of core-shared-lib element. Apparently, I need to perform an operation as soon as the library loads, and the Polymer's ready event gets fired before the library is downloaded. Is there a way that I can bind an event to core-shared-lib element so that I can execute that library's functions.
Thank You
There is a on-core-shared-lib-load event according to docs. Try that
<core-shared-lib on-core-shared-lib-load="{{load}}" url="https://apis.google.com/js/plusone.js?onload=%%callback%%">
I noticed that the OnNavigationCompleted event in the Catel's ViewModel overriden method did not fire for the first page. Is this by design?
Is there any way I could execute codes after the page has been loaded, not in the ViewModel's constructor itself?
Thank you!!
You should use the Initialize method. This method is always called when a view is loaded. The first page isn't caused by a navigation, so that's why you don't get a OnNavigationCompleted. The first page should be initialized in the Initialize method.
The architecture is based on the use of the following frameworks: Flex, Cairngorm and Parsley.
I use a dispatcher with an event "AdicionarItemVendaMercadoriaEvent" within a popuppanel: PopupPanel.
I capture the event with [MessageHandler] within the FormPM.as injected into Form.mxml.
Within Form.mxml, I have a mx: TabNavigator and each tab is within one s: NavigatorContent.
It turns out that when there is more than one open tab mx: TabNavigator the dispatched event is captured in all Form of all tabs.
Normal operation was to capture the only event of the tab where the PopupPanel was dispatched, not all tabs.
Please, any suggestions for solving this problem?
I appreciate the help.
How about using straight forward function callbacks?
When you create your PopUpPanel, pass in a function callback that you want to be executed when the popup is closed. Rather than using an event, you'd simply call the function. i.e.
Inside FormPM:
public function showPopup():void
{
var popup:PopUpPanel = new PopUpPanel();
popup.onCompletion = handleResult;
PopUpManager.addPopUp(popup, ...);
}
private function handleResult(someData:*):void
{
// My popup has completed.. what do I want to do with the result.
}
You might want to consider the Spicelib 3.0 command framework and have a command to popup your panel and then add the error/success callbacks to that: http://www.spicefactory.org/parsley/docs/3.0/manual/?page=commands§ion=intro
I am using GWT textbox.
Whenever textbox.setText() method is called, i want to perform an action in some other class.
ValueChangeEvent is not fired whenever setText() is called.
Is there any event that will be fired or any ways to achieve this?
Please help
You could try to use setValue(String value, boolean fireEvent) method
If you have a look at the TextBox.seText() method, you'll see that, all the way down to the actual DOM, no event is ever generated, so what you want to do simply won't work off-the-box.
I see two options:
Whenever you call setText, you also call the event handler of your choice or, much better
Make your own TextBox that extends TextBox, and override the setText() method so that it first calls super.setText() and then does whatever event generation you'd like
I want to attach my own key event handler to an INPUT that already has another event handler attached to onkeydown. Essentially, I want to receive a key event before all the other handlers and check if the user pressed a certain key -- if yes, I want to perform some functions and discard the event, if no, I want to pass it along to the other handler(s).
How can I do this with jQuery?
If you are loading a 3rd party script or jQuery addon you can just load your script or function first. If you do that then you can use something like this without the mess of unbinding and rebinding event handlers.
// your possible interceptor code
$("#awesome").keydown(function(e) {
if (e.keyCode < 70) {
e.stopImmediatePropagation();
console.log("BLOCKED!!!");
};
});
// possible 3rd party event code loaded after your code
$("#awesome").keydown(function(e) {
console.log("3rd party:"+e.keyCode);
});
Example webpage => http://mikegrace.s3.amazonaws.com/forums/stack-overflow/example-key-event-interception.html
Example output of Firebug console
jQuery stopImmediatePropagation() documentation
According to the jQuery bind() documentation:
"When an event reaches an element, all handlers bound to that event type for the element are fired. If there are multiple handlers registered, they will always execute in the order in which they were bound."
So it looks like you will have to unbind the other handlers, bind yours and then add the others back if you want yours to run first.
There is some good information in this thread with respect to that:
jQuery: Unbind event handlers to bind them again later