- converting DOM into jQuery Tab:
$('selector').tabs();
From now on, adding or removing tabs should be performed by Tabs API:
- adding a tab: $('...').tabs('add','#tab-id', 'tab title');
- removing: $('...').tabs('remove', tabIndex);
Complete documentation: http://jqueryui.com/demos/tabs/
I have forked angular-seed and created a jquery-tabs branch:
https://github.com/witoldsz/angular-testfield/tree/jquery-tabs
As of now it works like this:
one has to provide a markup:
<div my:tabs="someArray">
<div class="template"> ...markup... </div>
</div>
example:
https://github.com/witoldsz/angular-testfield/blob/jquery-tabs/app/index.html
And this is how widget's source code looks like:
https://github.com/witoldsz/angular-testfield/blob/jquery-tabs/app/js/widgets.js
Controller is, of course, not aware of all that "tabs case":
https://github.com/witoldsz/angular-testfield/blob/jquery-tabs/app/js/controllers.js
My widget works like this:
- at the very beginning it:
-- adds empty: <ul></ul> node,
-- hides a template div,
-- applies $(...).tabs() to make it a jQuery UI Tabs component,
- then it applies a watch on the size of the provided array:
-- first time it iterates over all the array's elements to create tabs,
-- each time the array changes it size, it adds or removes the tabs.
That was easy. Here comes the problems - for full functionality, I
should create a sub-scope for every tab, so the template markup could
be resolved and notified on content changes - this is how ng:repeat
works. I was trying to transfer ng:repeat's solutions into my widget,
but it seems to be too much complicated for me (the "compiler" is yet
to be tamed by me :). I think the other problem is that, I don't know
why, the Angular's internat API is totally different from SPI. Why it
is like this? How would the ng:repeat widget look like if it was
created using documentation of widgets and scopes? I think, creating
new widgets would be easier if built-in widgets looked the same as
custom ones.
Can you help me finishing the Tabs? I think it would be very helpful,
for the community, to have a solution for the complex widget like this
:) :)
Thanks,
Witold Szczerba
--
You received this message because you are subscribed to the Google Groups "angular" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
Thanks again,
Witold Szczerba
2011/5/16 Misko Hevery <mi...@hevery.com>:
So I was thinking about something like this:
<my:tabs> <!-- tabs' container -->
<my:tab title="first title expression"> first tab...</my:tab>
<my:tab title="second title..."> second tab... </my:tab>
<my:tab controller="ThisIsOptionalCtrl" loop="for p in persons"
title="{{p.firstName}} {{p.lastName}}">...</my:tab>
<my:tab title="last title..."> final tab... </my:tab>
</my:tabs>
The loop expression could be more flexible, eg.:
- "for p in persons"
- "persons" (shortcut for the above)
- "for (key, value) in someObject" (works like in ng:repeat)
That all would be awesome! :)
Maybe I could persuade my friend to create such a component and give
it community.
Oh, I have forgot: Misko, you have said:
> You will need to keep track of the childTabScopes and call $eval on them
what does it means exactly in my case?
Thanks,
Witold Szczerba
2011/5/16 Misko Hevery <mi...@hevery.com>:
https://github.com/witoldsz/angular-testfield/blob/jquery-tabs/app/index.html
https://github.com/witoldsz/angular-testfield/blob/jquery-tabs/app/js/widgets.js
https://github.com/witoldsz/angular-testfield/blob/jquery-tabs/app/js/controllers.js
Fell free to use/modify/adopt it, but this is a prototype-quality code
and it does not implement the cool features I have mentioned before -
like mixing constant and dynamic tabs or allowing some or all tabs to
be loaded just-in-time, so invisible tabs would not occupy DOM and CPU
time (many controllers watching and tracking invisible tabs).
By the way - is this possible to somehow temporarily "freeze"
controllers or selected DOM elements, so we could keep invisible tabs
in DOM, but in a way they would not take CPU time for 2-way data
binding?
Regards,
Witold Szczerba
2011/5/17 Misko Hevery <mi...@hevery.com>:
To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.