jquery calendar: define custom icon - jquery-ui

when having a calendar widget assigned to a textbox, how can i trigger it from a separate icon? (i don't mean the internal showOn button feature).

you can bind the separate icon with an event calling this function
$('#your-datepicker').datepicker('show');
look like
$('input#mybutton').click(function(){
$('#datepicker').datepicker('show');
});

Related

Vaadin23 tooltip component

I need to show users different tooltips on mouse over event. Do we have something like that in Vaadin component library? If no, how to show tooltips in Vaadin23?
You could use also get the root element of whatever component you want the tooltip for and set the attribute:
Button button = new Button("Example");
button.getElement.setAttribute("title", "This is the tooltip");
There is an addon for tooltips https://vaadin.com/directory-beta/addon/tooltip
There is also ongoing work on adding tooltips to the core framework, you can follow the discussion here https://github.com/orgs/vaadin/discussions/3196

How do you use the showhide effect found in the Dart Widget Package

I am trying to use the ShowHide effect that comes with Kevin Moore's widget package here:
http://dart-lang.github.io/widget.dart/#showhide
Not sure how to use this. Anyone got an example I can look at ?
Basically all I want is for a dropdown to show with one of those effects if a certain event happens.
Your tips appreciated.
Thanks.
You need to add a listener for an event to an element in the DOM, and then use ShowHide.toggle(element, effect) to trigger an effect. Here is an example which listens for a click on a button, and toggles FadeEffect on an image each time it is pressed:
var button = query("#fadeButton")
..onClick.listen((event) {
ShowHide.toggle(query("#fadeImage"), effect: new FadeEffect());
});
If you wanted to fade in/out a dropdown when you click on a menu bar, then substitute "fadeButton" for the menu which listens for clicks, and "fadeImage" with the dropdown element.
Also, any other effect can be substituted for FadeEffect, such as DoorEffect, ScaleEffect, ShrinkEffect, etc.

DART - Resize div element event

I am using CSS3 resize: vertical; to allow the user to resize a Div, and would like to be notified when this happens (so that I can adjust the size of other elements with Dart code if necessary).
How can I attach an event listener for the user resize event?
( DivElement.on.resize does not exist.)
When you want to observe event which is not listed under the on getter, you can use $dom_addEventListener to set event listener.
Thus, if you would like to use something like the unexisting divElement.on.resize, you can use :
divElement.$dom_addEventListener("resize", (e) {
// event occurs
});
That said, unlike click event, the resize event doesn't seem to be fired (even in javascript).

Prevent an element within header from expanding

I'm using jQueryUI Accordion, and genereate the elements on the fly. I need to prevent accordion expanding if we click Remove action link inside the header.
To stop further handlers from executing after one bound using .live(), the handler must return false. Calling .stopPropagation() will not accomplish this.
No luck with return false. Please see the demo.
I don't think you will have too much luck achieving what you want with live(), as jQuery only supports event bubbling and not event capturing. The design decision was probably due to the fact the IE does not support event capturing, even though W3C's speicification has the flexibility for both.
Your best bet is to attach a click event to the remove button right after it is inserted into the DOM (to stop the event propagation) before you re-initiate the accordion. You may need to take care not to bind click event to the existing remove buttons multiple times.
The pseudocode would look something like this:
call .accordion('destory') on the current accordion
create the new element, i.e. <h2>...<a class="revmoe">...</a></h2><div>...</div>
insert the new element to the existing accordion
bind a click event to the remove button in the new element to stop event propagation
initiate the accordion, i.e. .accordion({..})
SO posts on event capturing in jQuery:
event capturing with jQuery
Event Capturing vs Event Bubbling
Just use the given functions by the plugin:
$('#accordion').accordion({active:8, disabled:true});
jQuery('.remove').click(function(){
$('#accordion').accordion('disable');
})
I chose the option "active:8" because this way no header is opened from the beginning (index -1 does not work for IE). Check the function and options out at: http://docs.jquery.com/UI/Accordion
Hope this is what you were looking for :-)

jQuery .datepicker("setDate",newdate) is not triggering onChange nor onSelect events

The contents of the datepicker input is changed programmatically via "setDate" method and I want to update the preview of the input form depending on the changed date value.
The "onSelect" event is triggered only when the date is changed through the datepicker UI and not when "setDate" is called.
"onChange" event of the input is also not triggered.
Right now it seems the only way is to call my updatePreview function manually every time after the "setDate" and I have to re-format the date object I get from the "getDate" method.
Is there an easier way to do it?
Here's the mockup in jsFiddle. The "change programmatically" button doesn't update the preview.
If I am understanding correctly, you want to update a separate element with the date being entered or set programmatically. If so, updating an alternate field preview is baked into jQuery UI Datepicker already.
The datepicker widget only seems to be able to update an alternate <input> field rather than a <div> preview though, so if you need it to update a <div> then this demo will require a bit more work.
You could trigger the event yourself, but in general setting values in javascript does not trigger events. This goes for jQuery too.
Firing the events yourself:
$(elem).select(); // for select obviously
$(elem).change(); // for change

Resources