Selector, droppable, and ajax
I need to say that I am not strong at Javascript nor jQuery. So my questions may be novice. I have something like followings:
- <div id="droppable">
- <table>
- <thead>
- <tr>
- <th class="span-2">Column 1</th>
- <th class="span-1">Column 2</th>
- <th class="span-1">Column 3</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td class="span-2">...</td>
- <td class="span-1">...</td>
- <td class="span-1">...</td>
- </tr>
- </tbody>
- </table>
</div>
and
- <script type="text/javascript">
- $(document).ready(function () {
- var itemName = document.getElementById("name").value;
- var options = {
- caption: false,
- navigation: 'hover',
- direction: 'right'
- }
- ...
- $("#droppable").droppable({
- tolerance:'touch',
- drop: function() {
- $(this).append("<tr><td class='span-2'>").append("new item").append("</td><td class='span-1'>").append("1").append("</td><td class='span-1'>").append("10.00").append("</td></tr>");
- }
- });
- });
- </script>
I get all data in the droppable box and it functions as designed. The data format is not correct, however. I think it is caused by an incorrect selector. I believe that path shall be "table tbody", but just can't put it right.
And what is a right way to refer a string on the same page? I try to get a string in the element ID "name", but append(document.getElementById("name").value) inside of the drop: function() yields a blank.
Also, how to invoke a URL like /somethings/doSomething inside of the drop: function()? I need to call a server function when something is dropped into the droppable box.
Thanks for your inputs in advance.