I am attempting to work an existing web app to use Kendo (Mobile) UI widgets.
All of the existing javascript code base is contained within AMD modules (RequireJS).
I would like to attach a 'show' event handler to a view, so that the app can request data from the back end, however the data logic is within a module, and cannot be called from the page script (and thus, I can't use Kendo data-event attributes).
I thought that I would be able to to attach an event handler in code like so:
$('#tabstrip-browse').on("show", function(e) {...});
however, the event handler is not called.
Is there a way to do this?
Seems I'm finally able to answer my own question
My issue was that I was trying to use jQuery event binding syntax to bind to the events, however, KendoUI does not expose events in a jQuery friendly/compliant way.
However, there is a way to do this using the KendoUI API
There is no standard 'show' event in javascript or jQuery. You can bind custom events, but you need to also include a way to trigger them.
Here's a trivial example:
// bind the custom event
$('#element').on('show', function(e) {
// handle the custom event
});
// trigger the custom event
$('#element').trigger('show');
There is an attach event on Durandal
https://groups.google.com/forum/#!topic/durandaljs/UQ9hXpwP_ds
Related
I am trying to merge surveyjs along with my NativeScript application. I have referred URL for merging the same with Angular application
From the Angular demo code given on website, we have to add event handler for Complete button where we can get the response from surveyjs. Is it possible to integrate similarly for Nativescript Mobile application? Here is the approach which i feel can be taken.
Display
Create a HTML as provided by SurveyJS with required CSS and JS
referenced and add them as a file in project.
Modify HTML once i get the survey question json back from server.
Show the HTML as part of WebView. This will take care of displaying
the survey on my Application.
Here are my challenges during Submission
As per the process given on SurveyJS, i need to add handler for
oncomplete which will get the result json for me. How can i add
handlers for Complete button click in my code? Also please note that
there is a possibility that there may be multiple surveys on a single
page.
Apart from Survey, there are other fields also on the page and user
will submit them all in one go by clicking submit button of the page.
Hence i am planning to hide Complete button provided by SurveyJS
page. This needs to be triggered via code. Can this be done?
If someone can give directions on whether this scenario can be handled in nativescript application with Angular,it would help immensely.
yes it can be done using nativescript-webview-interface plugin.
add jS code inside WebView to handle oncomplete event from surveyJS. and on that function call emit some event to native app. after that add nativescript code to listen for that event and get the JSON back.
inside webView JS function
var oWebViewInterface = window.nsWebViewInterface;
// emit event to native app
oWebViewInterface.emit('anyEvent', jsonData);
inside native App
oWebViewInterface.on('anyEvent', function(jsonData){
// perform action on event
});
for more details on this you can check plugin readme file https://github.com/shripalsoni04/nativescript-webview-interface
With jQuery, I can attach an event handler function via the on method that will be triggered also when the DOM change and something (like an Ajax call) replace the HTML of the page.
Is it possible to do something similar with a React component? After an ajax call that changes the DOM, if an element with a specific class is found, render it (with ReactDOM.render(...)).
Thanks
The component render responsibility should be given to react. Hence you should store the response from ajax call in the current state and react will handle the component rendering based on current state.
Follow these APIs if you are using only react
https://facebook.github.io/react/docs/component-api.html
or follow connect() if you are writing in react-redux
I have a custom panel with a couple of components, eg. a button and a text box.
Once the button is clicked I would like custom panel that is also the parent panel receives the event and decides what to do, like call setText on the textbox.
Is it possible to achieve this using an eventbus ?
This means that the child components need not handle their event and then relay it.
I don't know the exact classes and how they work together. But sure you could use the GWT EventBus to achieve this. Fire an event in your button class and handle this event in your custom panel. You can google or find related answers here on stackoverflow.
I think this answer will help you: How to use the GWT EventBus
It's pretty simple to fire events and handle this events in other classes in your application.
I 've seen many WP7 applications, some place event handlers in code, some place event handlers in XAML
Should we add event handler in XAML?
Does that handler automatically unsubscribe to the event when the page is navigated from ?
You can do either, it really doesn't matter! And no, you do not have to worry about adding / removing event handlers when the user navigates from one page to the next. When a page is no longer needed, it is destroyed.
The only time you might want to handle things differently is if you are using the MVVM pattern, when you might want to use commands rather than event handlers.
I'm developing an Lotus XPages solution. I have a Custom Control that I would like to have additional functionality in the form of an event call-back.
Is it possible to create a JavaScript callback or event in a custom control? What I'd really like is to add events to one of my controls, something like OnSomething or querySomething and postSomething, so that when the event is fired, the code at the calling end is properly called.
Can it be done??
Thanks!