Angular dart click event on <a> href that is wrapped in shadow dom is retargeted to wrapper - dart

In Angular dart tutorial Chapter_06, the default router is based on hash. After change it to Html 5 push state, the route on edit button which is inside of view_recipe_component does not work.
After check a while, it turns out it is because, the link of edit button is inside of shadow dom, so the click event is retargeted to <view-recipe> element (the wrapper of shadow dom). Then the DefaultWindowClickHandler can't get desired element, therefore it does not fall into router's control.
So what should I do to handle this event retargeting in shadow dom in router of angular dart? or is there any existing solution in angular dart?

Related

Is there an HTML DOM equivalent to JqueryUI selectable?

Since there are HTML DOM attributes to make an element draggable, droppable and resizable, is there something like it for selectable?
I want to remove JQueryUI dependency (and not replace it with another library) since we don't use the widgets anymore, just the convenience methods for widget handling. When I keep selectable, widgets don't respond to the HMTL attribute settings (Jquery UI takes over drag/drop/resize).

Deciding between NgComponent and NgDirective

Is there some rule of thumb to be followed while deciding to implement custom element as NgComponent or NgDirective?
What are the issues to keep in mind while deciding to choose either of them?
If you want to add functionality/behavior to existing tags/elements you use a directive (like ng-class or ng-hide).
You can apply a directive to different tags.
To create a new element/tag you create a component (like accordion, carousel, modal, ...).
A component is a new custom element that can have a template that defines its shadow DOM content.
You can use a directive to dynamically add/remove html content too, but with a component you can create new elements that have a clear boundary between inside and outside.
A component has it's own scope that is not part of the application scope hierarchy.
You can't easily reach inside a components content.
Html generated from a directive is like any other html tags. You have transclusion with components (I think someone is working on components without shadow DOM and transclusion like in Angular.js but I don't know how far this is and how this will look like.)
You can use directives inside a component, and a component inside a component.

how can I trigger an angular change event with a jquery UI slider?

Originally, I had a text input setup with a ng-model attribute, so that when changing its value, it would trigger something else on the page that was utilizing that model attribute. I have replaced that text input with a jQuery UI slider, and am curious what the correct or "angular" way to interact with this element so that the slider's change event / function can delegate directly to angular and accomplish the same sort of thing.
Take a look at the ui-slider component of angular-ui to see a solution for your situation.

Is there a way to use JQM button styling outside of a Page or Header data-role?

I just started working with JQM a little while ago. I used the default VS2012 asp.net mobile project to start with. I like how the mobile pages work, but wanted a fixed area at the top of each page that essentially has 3 columns one of which is a logo. I've done that (with a basic table to start with) in the _layout.cshtml, and right below that is where I start the JQM Page layout. This is all working well, and I like how the page transitions happen while keeping a fixed header area at the top.
However, I would like to add a button to my fixed area at the top that is styled similar to the other JQM buttons. This doesn't work because the buttons are not within a valid Page or Header data-role I presume. Is there a way to take advantage of the JQM styles for HTML that is outside of those data-roles?
As an example, I'd like to use the anchor tag for a Log In button and have it styled the same as it is with a gear-icon when it's within a div that has data-role = "header". I'm not sure I have a deep enough understanding to drill down through all the elements that are used in the .css file and was hoping there are other individual classes or something I can take advantage of.
This is the line I am trying to display as a button, but I am only getting text (does work as anchor tag though):
<a data-role="button" data-transition="pop" href="/Vision/Account/Login">Log in</a>
Also, I am using jquery.mobile-1.1.0 and jquery-1.7.2.
You can style any element as a button by calling the jQuery Button Widget on the element:
$('.login-button').button();
The button function also accepts options such as the icon and theme:
$('.login-button').button({
icon: 'gear'
});
See also: http://jquerymobile.com/test/docs/buttons/buttons-options.html
Try adding data-role="button" to your anchor tag.

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 :-)

Resources