Commits

Anonymous committed 04fdbcd

support <select multiple> for HTSQL 2.0

Comments (0)

Files changed (2)

htraf/examples20/index.html

 </head>
 <body>
     <h3>Select a School</h3>
-    <select id="school" 
+    <select id="school" multiple
         data-htsql="/school{code, name}?exists(department)"></select>
     <div style="width: 500px; height: 350px;" 
         data-htsql="/program{title, count(student)}

htraf/js/htraf.widgets.js

         LOCAL: 'data-bind',
         WIDGET: 'data-widget',
         REF: 'data-ref',
+        SERVER: 'data-server',
+        HTSQL_PREFIX: 'data-htsql-prefix',
         CHANGE: 'change',
         BEFORELOAD: 'beforeload',
         AFTERLOAD: 'afterload',
     _updateAttr: {},
 
     _setupSource: function() {
+        var server = this.element.attr(SERVER);
+        this._htsqlPrefix = (server ? 
+            $('script[' + SERVER + '="' + server + '"]').attr(HTSQL_PREFIX)
+            : HTRAF.htsqlPrefix) || HTRAF.htsqlPrefix;
+
         if(this._ref)
             this._removeRef();
         else
             else {
                 var s = [];
                 $.each(vars, function(key, value) {
-                    s.push('$' + key + ':=' + escape(value)); 
+                    var e = escape(value);
+                    if(e.substr(0, 1) == '[') // sort of hack
+                        e = '{' + e.substr(1, e.length - 2) + '}';
+                    s.push('$' + key + ':=' + e); 
                 });
                 s = s.join(',');
                 url = url + (s ? ' :where(' + s + ')':'') + formatter;
             }
         }
-        return HTRAF.htsqlPrefix + url;
+        return this._htsqlPrefix + url;
     },
 
     _loaded: function(data) {