What's the difference between .modal('show') and shown.bs.modal? - bootstrap-modal

Calling a modal via Javascript, when do I use $('#myModal').on('show.bs.modal', function()) and when to use $('#myModal').modal('show')?

Based on Bootstrap 3 documentation:
.modal('show')
Manually opens a modal. Returns to the caller before the modal has actually been shown (i.e. before the shown.bs.modal event occurs).
Due to how HTML5 defines its semantics, the autofocus HTML attribute has no effect in Bootstrap modals. To achieve the same effect, use some custom JavaScript:
$('#myModal').on('shown.bs.modal', function () {
$('#myInput').focus()
})
This event fires immediately when the show instance method is called. If caused by a click, the clicked element is available as the relatedTarget property of the event.

Related

CWebBrowser2 (MFC) GoBack method causing crash when it has nothing to go back to

My application supports the IE (InternetExplorer) browser. When the back/forward buttons are clicked and there is nothing to go back or forward to, Webbrowser.GoBack() and Webbrowser.GoForward() are causing a crash.
Is there any way to know if I can go back before I actually call GoBack()? I took a look at the CWebBrowser2 class functions, but I couldn't find anything as such.
Is there any API to help on this, or any alternative approach to handle this?
Is there any way to know if I can go back before I actually call GoBack()?
Per the IWebBrowser2::GoBack() documentation:
Use the DWebBrowserEvents2::CommandStateChange event to check the enabled state of backward navigation. If the event's CSC_NAVIGATEBACK command is disabled, the beginning of the history list has been reached, and the IWebBrowser2::GoBack method should not be used.
And likewise in the IWebBrowser2::GoForward documentation:
Use the DWebBrowserEvents2::CommandStateChange event to check the enabled state of forward navigation. If the event's CSC_NAVIGATEFORWARD command is disabled, the end of the history list has been reached, and the IWebBrowser2::GoForward method should not be used.
And per this discussion thread:
Create a couple of BOOL member variables in the class that processes the
ON_UPDATE_COMMAND_UI notifications for the 'back' and 'forward' toolbar
buttons -- one for each button state. Initialize them both to FALSE in
the ctor. Handle the OnCommandStateChange event, and watch for the
CSC_NAVIGATEBACK and CSC_NAVIGATEFORWARD values in the 'nCommand'
parameter. When you get the CSC_NAVIGATEBACK value store the 'Enable'
parameter value into your BOOL member variable for the 'back' button
state. Do the same thing for the 'forward' button state variable when
you get CSC_NAVIGATEFORWARD value. In your OnUpdateButtonForward and
OnUpdateButtonBack handlers, call pCmdUI->Enable using the corresponding
button state member variable.
So, use the browser's CSC_NAVIGATE... state changes to know when it is safe to call GoBack()/GoForward()`. These are the same events that IE uses to enable/disable its own Back/Forward UI toolbar buttons.

Set focus on component after modal close

I would like to know what is recommended way to focus on component from outside the component. I am trying to focus on a input field when the person closes the modal window.
Typically you would use an action in the modal that triggers when the close button is clicked, and you would send the action up to the component with the input with sendAction. In the component with the input, you could then use Ember.$ or any other method to tell the browser to focus on an element.
The situation is more complex if the modal is not inside the component that contains the input. In that case you might need to use a service or event. But it's much easier to use the first method.

Get data from Double click on non-editable Kendo Scheduler

I tried to get the data for empty kendo scheduler. Mean no event. I try to extract atleast start time, end time and date. I off the editable. mean I not use the window that kendo provided. I try to custom by using bootstrap modal.
here is my event delegate
$("#scheduler").delegate('.k-event', "click", function (e) {
debugger;
});;
I can get the event on this scheduler, but i cant extract data without event.
To get the underlying event object from event element you can get it's data-uid attribute and pass it to the occurrenceByUid method. Demo is available in the method description (check the link).

How can I send a specific action from a component based on some conditions?

I am extending Ember.TextField (which extends Ember.Component) in order to read a file. My intent is if the chosen file satisfies some conditions, send an action to the controller. But if it fails, send a different action. However when I try to do this, no action is called.
I created a jsbin of what I am trying to do.
You need to send in what the action should map to in that scope when you create the component, in your case they are the same action name, but in other cases, the component could be calling acceptChanges and it could be hitting the controller action acceptImageChanges where-as another may be acceptDocumentChanges. This allows you to use the component multiple times in the same scope, yet have the actions that are passed out of it be customized per instance.
{{view App.ImportFileView invalidFileType='invalidFileType' acceptChanges='acceptChanges' }}
http://emberjs.jsbin.com/tonorida/10/edit

Global event listeners in wxPython

I have a wx.html2 widget in my panel. Sadly wx.html2 doesn't have many event listeners (http://wxpython.org/Phoenix/docs/html/html2.WebView.html#events-events-emitted-by-this-class).
Now I have this binding to my panel (self is the panel);
self.Bind(wx.EVT_KEY_DOWN, self.OnRightClick)
.. and it works when I type in a blanco panel/frame as intended.
I wonder if there is a way to add more event listeners to the wx.html2 manually or make a global event listener that listens, no matter the sub-widget the event happens in.
This does not work either (self.wv is the wx.html object);
self.wv.Bind(wx.EVT_KEY_DOWN, self.OnRightClick)
Update
I'm fixing the catching of keys/mouse-actions with JavaScript inside my HTML page now. It works, but I would like it more that actions can be bound to the wx.html2 object.
There are only a few events emitted by WebView, all of which can be found in WebView - wxPython (Phoenix) 2.9.5.80 documentation.