Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#7676 closed bug (invalid)

How Can I Be The Only One To Notice THIS!!!!

Reported by: jpe.pinho@… Owned by:
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.4
Keywords: jqueries Cc:
Blocked by: Blocking:

Description

i have 3 templates wrapped inside script tags marked as text/html (<script id="HeaderTt" type="text/html">...</script>) and the first template contains the following: "<table><thead><tr><td>HELLO</td></tr></thead><tbody>"

the second contains: "<tr><td>${something}<td/></tr>"

the last contains: "</tbody><tfoot><tr><td>MORE HELLO</td></tr></tfoot>"

considering the templates above, i wrote the following script:

...

var t1 = $.template(null, firstTemplate.innerHTML); var t2 = $.template(null, secondTemplate.innerHTML); var t3 = $.template(null, thirdTemplate.innerHTML);

now if i do:

$.tmpl(t1, null).appendTo(someHTMLControl);

the output will be:

"<table><thead><tr><td>HELLO</td></tr></thead><tbody>?<DIV></DIV></TBODY></TABLE>"

now from the question mark forward what HAPPENED??? what the hell are that? is jquery trying to correct my template?!?! why?! i'm frustrated... i tried to change from prototype to jquery on this project i made, and i end up using prototype because in the end of the day it was PROTOTYPE the one that solved my problems!!! their templates are much more straight forward (although i recognize that jquery has more potencial due to databing functionalities). The problem here is that 99.9 percent of the users expect the output without that final part, so what ever you guys do, your first priority is to handle that cenario or at least explain it! Develop is very funny, but we cannot forget that or purpose of existance is to solve OTHER PEOPLE PROBLEMS.. if we forget that, we are just some geeks...playing with our computers...

P.S: i'm not trying to be offensive, i'm just sharing my point of view.

Regards,

JP

Change History (2)

comment:1 Changed 8 years ago by ajpiano

Resolution: invalid
Status: newclosed

jQuery requires that you pass strings that represent fully valid html elements. This is not unique to jQuery templates, but it is in fact true of all jQuery manipulation methods.

It's the reason that you can't do this:

$("<div>").appendTo("#foo")
$("Hello there").appendTo("#foo");
$("</div>").appendTo("#foo");

but rather you do $("<div>Hello There</div>") which jQuery can parse into a valid document fragment. JavaScript does not think in terms of markup strings, but rather Elements.

It is unfortunate that your expectation is so divergent with the way that jQuery works, but this is the way jQuery works. Your statement that 99.9 per cent of the users expect it to work your way is clearly not based in fact, as a great many jQuery users understand this problem intuitively, having had JS experience, and others learn it when they are informed. We understand that you are not trying to be offensive, but it is worth doing a bit of research before ranting as you have here.

Thanks for your time and interest in helping jQuery!

Last edited 8 years ago by ajpiano (previous) (diff)

comment:2 Changed 8 years ago by dmethvin

Keywords: jqueries added
Note: See TracTickets for help on using tickets.