Hook up the new jquery plugins in base.html and _as_table_row.html
authorSverre Rabbelier <srabbelier@gmail.com>
Wed, 04 Feb 2009 23:06:48 +0000
changeset 1215 b21e40ef8dad
parent 1214 7fb705534dd1
child 1216 ec4f1dd84b39
Hook up the new jquery plugins in base.html and _as_table_row.html A very important todo here is to make loading these plugins only when needed, as to not waste bandwith. This should be trivial to do later on though, so leaving as-is now. Patch by: "Mario Ferraro" <fadinlight@gmail.com> Reviewed by: Sverre Rabbelier
app/soc/templates/soc/base.html
app/soc/templates/soc/templatetags/_as_table_row.html
--- a/app/soc/templates/soc/base.html	Wed Feb 04 23:04:10 2009 +0000
+++ b/app/soc/templates/soc/base.html	Wed Feb 04 23:06:48 2009 +0000
@@ -17,6 +17,8 @@
   <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
 	{% block stylesheet %}
   <link rel="stylesheet" href="/soc/content/css/soc-090120.css" type="text/css"/>
+  <link rel="stylesheet" href="/soc/content/css/jquery.autocomplete.css" type="text/css"/>
+  <link rel="stylesheet" href="/soc/content/css/thickbox.css" type="text/css"/>
 	{% endblock %}
   <title>
     {% block page_title %}
@@ -31,6 +33,10 @@
 	<script src="/jquery/jquery-bt-0.7.js"></script>
 	<script src="/soc/content/js/menu-081108.js"></script>
 	<script src="/soc/content/js/tips-081027.js"></script>
+	<script type='text/javascript' src='/jquery/jquery.bgiframe.js'></script>
+	<script type='text/javascript' src='/jquery/jquery.ajaxQueue.js'></script>
+	<script type='text/javascript' src='/jquery/jquery.autocomplete.js'></script>
+	<script type='text/javascript' src='/jquery/jquery-thickbox.js'></script>
 	{% block scripts %}{% endblock %}
  </head>
 {% block body_tag %}
--- a/app/soc/templates/soc/templatetags/_as_table_row.html	Wed Feb 04 23:04:10 2009 +0000
+++ b/app/soc/templates/soc/templatetags/_as_table_row.html	Wed Feb 04 23:06:48 2009 +0000
@@ -31,6 +31,23 @@
   </td>
   {% endblock %}
   <td>
+  {% if select_url %}
+    <script type="text/javascript">
+      $.getJSON("{{ select_url }}",
+        function(data){
+          $("#{{ field_id }}").autocomplete(data.data, {
+            matchContains: true,
+            formatItem: function(item) {
+              return item.link_id+" ("+item.name+")";
+            },
+            formatResult: function(item) {
+              return item.link_id;
+            }
+          });
+        }
+      );
+    </script>
+  {% endif %}
     {{ field }}
   </td>
 
@@ -40,19 +57,9 @@
   <td></td>
   {% endif %}
 
-  {% if select_url %}
-  <td><input type="button" onclick="location.href='{{ select_url }}'" value="Select"/></td>
-  {% else %}
-  <td></td>
-  {% endif %}
-
   {% if example_text %}
     <td class="formfieldexample">{{ example_text|safe }}</td>
   {% else %}
-    {% if select_url %}
-      <td class="warning">(discards unsaved changes)</td>
-    {% else %}
       <td></td>
-    {% endif %}
   {% endif %}
 </tr>