Click here to Skip to main content
15,887,683 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: Borderline programing question sorry.. :'( Pin
Richard Deeming29-Jan-15 8:08
mveRichard Deeming29-Jan-15 8:08 
GeneralRe: Borderline programing question sorry.. :'( Pin
Super Lloyd29-Jan-15 12:48
Super Lloyd29-Jan-15 12:48 
AnswerRe: Borderline programing question sorry.. :'( Pin
Kornfeld Eliyahu Peter29-Jan-15 9:00
professionalKornfeld Eliyahu Peter29-Jan-15 9:00 
GeneralRe: Borderline programing question sorry.. :'( Pin
Super Lloyd29-Jan-15 12:49
Super Lloyd29-Jan-15 12:49 
AnswerRe: Borderline programing question sorry.. :'( Pin
Afzaal Ahmad Zeeshan6-Feb-15 20:37
professionalAfzaal Ahmad Zeeshan6-Feb-15 20:37 
GeneralRe: Borderline programing question sorry.. :'( Pin
Super Lloyd6-Feb-15 22:13
Super Lloyd6-Feb-15 22:13 
QuestionAdvanced HTML (client side) Templating: Custom Markup Pin
Super Lloyd24-Jan-15 17:30
Super Lloyd24-Jan-15 17:30 
AnswerRe: Advanced HTML (client side) Templating Pin
Super Lloyd24-Jan-15 20:30
Super Lloyd24-Jan-15 20:30 
I found a way!!! Big Grin | :-D

Say I want to render that:
HTML
<rs-tabpanel>
	<tab>
		<header>01</header>
		<content>tab 01</content>
	</tab>
	<tab>
		<header>02 <i>hehe</i></header>
		<content>no worries!</content>
	</tab>
	<tab>
		<header>hah</header>
		<content><b>uit's alive</b></content>
	</tab>
	<tab>
		<header>foo</header>
		<content>snafu!</content>
	</tab>
</rs-tabpanel>


I used the following TypeScript VueJS component
JavaScript
function guid(): string {
	var d = Date.now();
    var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = (d + Math.random() * 16) % 16 | 0;
        d = Math.floor(d / 16);
        return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
    });
    return uuid;
}
function createHTML(name: string, attributes: any): HTMLElement {
	var res = document.createElement(name);
	for (var k in attributes) {
		res.setAttribute(k, attributes[k]);
	}
	return res;
}
module RSComponents {
	export class RSTabPanel extends Vue {
		constructor(options: any) {
			var init = {
				template: '#RSTabPanel',
			};
			$.extend(options, init);

			var el: HTMLElement = options.el;
			if (el.children.length > 0) {

				var panel = createHTML('div', { role: 'tabpanel', class: 'panel panel-default' });
				var headers = createHTML('ul', { role: 'tablist', class: 'nav nav-tabs' });
				var contents = createHTML('div', { class: 'tab-content panel-body' });

				for (var i = 0; i < el.children.length; i++) {
					var item: HTMLUnknownElement = <HTMLUnknownElement>el.children[i];
					var h: HTMLUnknownElement = <HTMLUnknownElement>item.children.item(0);
					var c: HTMLUnknownElement = <HTMLUnknownElement>item.children.item(1);
					var uid = guid();

					var attrs: any = { role: 'presentation' };
					if (i == 0) attrs['class'] = 'active';
					var he = createHTML('li', attrs);
					var heLink = createHTML('a', { href: '#' + uid, role: "tab", 'data-toggle': 'tab' });
					heLink.innerHTML = h.innerHTML;
					he.appendChild(heLink);

					attrs = { role: 'tabpanel', class: 'tab-pane', id: uid };
					if (i == 0) attrs['class'] += ' active';
					var ce = createHTML('li', attrs);
					ce.innerHTML = c.innerHTML;

					headers.appendChild(he);
					contents.appendChild(ce);
				}

				panel.appendChild(headers);
				panel.appendChild(contents);
				options.template = panel.outerHTML;
			}
			super(options);
		}

	}
	Vue.component('rs-tabpanel', RSTabPanel);
}

The important bit here, I replace the template option is there are children in my component!
All in one Menu-Ribbon Bar
DirectX for WinRT/C# since 2013!
Taking over the world since 1371!


modified 25-Jan-15 5:13am.

SuggestionRe: Advanced HTML (client side) Templating Pin
Kornfeld Eliyahu Peter24-Jan-15 22:18
professionalKornfeld Eliyahu Peter24-Jan-15 22:18 
AnswerRe: Advanced HTML (client side) Templating Pin
Super Lloyd24-Jan-15 22:48
Super Lloyd24-Jan-15 22:48 
GeneralRe: Advanced HTML (client side) Templating Pin
Super Lloyd24-Jan-15 23:22
Super Lloyd24-Jan-15 23:22 
SuggestionRe: Advanced HTML (client side) Templating Pin
Kornfeld Eliyahu Peter24-Jan-15 23:26
professionalKornfeld Eliyahu Peter24-Jan-15 23:26 
GeneralRe: Advanced HTML (client side) Templating Pin
Super Lloyd25-Jan-15 0:29
Super Lloyd25-Jan-15 0:29 
GeneralRe: Advanced HTML (client side) Templating Pin
best cardiology hospitals in kerala3-Mar-15 22:42
best cardiology hospitals in kerala3-Mar-15 22:42 
QuestionWeb development vs desktop development Pin
Picaro201522-Jan-15 21:22
Picaro201522-Jan-15 21:22 
AnswerRe: Web development vs desktop development Pin
David Mujica23-Jan-15 3:30
David Mujica23-Jan-15 3:30 
GeneralRe: Web development vs desktop development Pin
Picaro201525-Jan-15 22:48
Picaro201525-Jan-15 22:48 
AnswerRe: Web development vs desktop development Pin
Mycroft Holmes26-Jan-15 12:00
professionalMycroft Holmes26-Jan-15 12:00 
GeneralRe: Web development vs desktop development Pin
Picaro201526-Jan-15 20:45
Picaro201526-Jan-15 20:45 
GeneralRe: Web development vs desktop development Pin
Mycroft Holmes27-Jan-15 3:25
professionalMycroft Holmes27-Jan-15 3:25 
QuestionSending php generated form data via Ajax from Dialog box Pin
DeepCodeTech22-Jan-15 21:07
DeepCodeTech22-Jan-15 21:07 
QuestionWeb Design Frameworks Pin
jason173499-Jan-15 5:31
jason173499-Jan-15 5:31 
GeneralRe: Web Design Frameworks Pin
Richard MacCutchan9-Jan-15 6:33
mveRichard MacCutchan9-Jan-15 6:33 
AnswerRe: Web Design Frameworks Pin
ZurdoDev9-Jan-15 6:59
professionalZurdoDev9-Jan-15 6:59 
AnswerRe: Web Design Frameworks Pin
Paul LeJoy23-Mar-15 21:50
Paul LeJoy23-Mar-15 21:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.