Commit df051c64 authored by Łukasz Nowak's avatar Łukasz Nowak

Reuse DOM trees to create containers.

parent aa00b73e
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<tal:block metal:fill-slot="main">\n <tal:block metal:fill-slot="main">\n
<div class="content">\n <div class="content">\n
<h1 i18n:translate="" i18n:domain="ui">Request a Software Instance</h1>\n <h1 i18n:translate="" i18n:domain="ui">Request a Software Instance</h1>\n
<input type="hidden" name="js_entry" id="js_entry">\n <div id="js_container"></div>\n
<script type="text/javascript">\n <script type="text/javascript">\n
$(document).ready(mainController());\n $(document).ready(mainController());\n
</script>\n </script>\n
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_EtagSupport__etag</string> </key> <key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts21351764.59</string> </value> <value> <string>ts21353467.93</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
...@@ -23,24 +23,21 @@ ...@@ -23,24 +23,21 @@
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
function drawSoftwareProductList(data) {\n function drawSoftwareProductList(data) {\n
$(\'#software_product_list\').remove()\n $(\'#software_product_container\').empty()\n
var ul = $(\'<ul>\');\n var ul = $(\'<ul>\');\n
ul.attr(\'id\', \'software_product_list\')\n
$.each(data, function(i,item){\n $.each(data, function(i,item){\n
sp_id = \'software_product_\' + \'\'+item.uid;\n
li = $(\'<li>\').appendTo(ul);\n li = $(\'<li>\').appendTo(ul);\n
var newElem = $(\'<img>\');\n var newElem = $(\'<img>\');\n
newElem.attr(\'alt\', item.title);\n newElem.attr({\n
newElem.attr(\'src\', item.image);\n \'alt\': item.title,\n
newElem.attr(\'id\', sp_id);\n \'src\': item.image,\n
newElem.attr(\'width\', \'100\')\n \'id\': item.uid,\n
newElem.attr(\'height\', \'40\')\n \'width\': \'100\',\n
\'height\': \'40\'})\n
newElem.appendTo(li)\n newElem.appendTo(li)\n
newElem.click(function() {\n newElem.click(softwareReleaseController);\n
alert(\'Clicked on \' + $(this)[0][\'alt\'] + $(this)[0][\'id\']);\n
});\n
});\n });\n
$("#js_entry").before(ul);\n $("#software_product_container").append(ul);\n
}\n }\n
\n \n
function updateSoftwareProductList() {\n function updateSoftwareProductList() {\n
...@@ -51,22 +48,29 @@ function updateSoftwareProductList() {\n ...@@ -51,22 +48,29 @@ function updateSoftwareProductList() {\n
drawSoftwareProductList);\n drawSoftwareProductList);\n
}\n }\n
\n \n
function softwareReleaseController() {\n
alert(\'Clicked on \' + $(this)[0][\'alt\'] + $(this)[0][\'id\']);\n
}\n
\n
function mainController() {\n function mainController() {\n
$.ajaxSetup ({ \n $.ajaxSetup ({ \n
cache: false \n cache: false \n
});\n });\n
\n \n
var newElem = $(\'<input type="text">\');\n var input = $(\'<input type="text">\');\n
newElem.attr(\'id\', "software_product_query");\n input.attr(\'id\', "software_product_query");\n
$("#js_entry").before(newElem);\n $("#js_container").append(input);\n
\n
var newElem = $(\'<input type="button">\')\n
newElem.attr(\'value\', \'Refresh...\')\n
$("#js_entry").before(newElem);\n
\n \n
newElem.click(updateSoftwareProductList)\n var newElem = $(\'<input type="button">\');\n
\n newElem.attr(\'value\', \'Refresh...\');\n
} newElem.addClass(\'bt-med dialog_submit_button\');\n
input.after(newElem);\n
software_product_container = $(\'<div>\');\n
software_product_container.attr(\'id\', \'software_product_container\');\n
newElem.after(software_product_container);\n
newElem.click(updateSoftwareProductList);\n
}\n
]]></string> </value> ]]></string> </value>
</item> </item>
...@@ -76,7 +80,7 @@ function mainController() {\n ...@@ -76,7 +80,7 @@ function mainController() {\n
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>1271</int> </value> <value> <int>1411</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
318 319
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment