-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insert agility object anywhere on the DOM #32
Comments
I thought you could. For instance, I built a test where I put it in the middle of my content like this: $$.document.append(list, $('#content')); Couldn't you do a similar selector with an ID or class in your table? |
Let's say you have:
Now I want to put this in the middle:
Using jQuery I could use:
|
Give this a try: <table>
<tr><td>1</td></tr>
<tr><td>3</td></tr>
</table> var test = $$({}, '<td>2</td>');
$$.document.append(test, $('<tr />').insertAfter('table tr:first')); |
I can only do that because in this case the "tr" has only one "td". :-)
|
haha.. now I see it's just a cat and mouse game. For that, unless I miss something, you would change it in your view. Something like this: <table>
<tr><td>1</td><td>Product1</td></tr>
<tr><td>3</td><td>Product3</td></tr>
</table> var test = $$({productID:0, productName:''}, '<td data-bind="productID" /><td data-bind="productName" />');
var myTest = $$(test, {productID:2, productName:'Product2'})
$$.document.append(myTest, $('<tr />').insertAfter('table tr:first')); |
The documentation says clearly:
|
Yeah, you're right. It doesn't throw an error on any of my tests, but would probably freak out if you start doing anything heavy with the controller. I was more or less using it like a template. The problem is you can't select empty space and pass it as as the "selector" to put the root element. That's why I halfed it by creating the root element on the fly, but the controller won't recognize that. Probably would be nicer if you could call the append method directly on a JQuery object, then it wouldn't matter. |
Hey guys, thanks for the brainstorming here. For completeness, I think it makes sense to have I've merged Fabio's (@quartzo) work, added some unit tests, and added a few touch-ups. Thanks! |
Now you can only insert an agility object at the beginning (prepend) or at the end (append) of the list of the children defined for a DOM object.
or
I need to put the agility object in the middle, after the "tr" that defines the header of the table and before the "tr" that show totals of the table.
The text was updated successfully, but these errors were encountered: