Permalink
Browse files

It works better now

  • Loading branch information...
1 parent 1b79284 commit 296cee5f7f942825244a4a6e5bce658b3ec5c637 @wycats wycats committed Dec 30, 2007
Showing with 100 additions and 25 deletions.
  1. +6 −4 autocomplete.html
  2. +3 −3 jquery.js
  3. +2 −2 jquery.min.js
  4. +68 −0 jquery.templating.js
  5. +5 −0 jquery.ui.autocomplete.ext.js
  6. +16 −16 jquery.ui.autocomplete.js
View
@@ -10,17 +10,19 @@
<link rel="stylesheet" href="jquery.ui.autocomplete.css" type="text/css" media="screen" />
<script src="jquery.js"></script>
<script src="jquery.dimensions.js"></script>
- <script src="jquery.ui.autocomplete.ext.js"></script>
+ <script src="jquery.templating.js"></script>
+ <script src="jquery.ui.autocomplete.ext.js"></script>
<script src="jquery.ui.autocomplete.js"></script>
<script>
$(function() {
$("input.autocomplete").autocomplete({
ajax: "list",
- template: function(obj) { return "<li>" + obj.text + "</li>"; },
- match: function(typed) { return this.text.match(new RegExp(typed)); },
+ match: function(typed) { return this.text.match(new RegExp(typed)); },
+ insertText: function(obj) { return obj.text },
+ templateText: "<li>Hey: <%= text %></li>"
})
.bind("activate.autocomplete", function(e, d) { console.log(d); })
- .bind("cancel.autocomplete", function(e) { console.log("Cancelled") });
+ .bind("cancel.autocomplete", function(e) { console.log("Cancelled"); });
});
</script>
</head>
View
@@ -2000,7 +2000,7 @@ jQuery.event = {
// Handle triggering of extra function
if ( extra && jQuery.isFunction( extra ) ) {
// call the extra function and tack the current return value on the end for possible inspection
- var ret = extra.apply( elem, data.concat( val ) );
+ ret = extra.apply( elem, data.concat( val ) );
// if anything is returned, give it precedence and have it overwrite the previous value
if (ret !== undefined)
val = ret;
@@ -2107,7 +2107,7 @@ jQuery.event = {
}
// Add which for key events
- if ( !event.which && (event.charCode || event.keyCode) )
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) )
event.which = event.charCode || event.keyCode;
// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
@@ -2356,7 +2356,7 @@ var withinElement = function(event, elem) {
// Check if mouse(over|out) are still within the same parent element
var parent = event.relatedTarget;
// Traverse up the tree
- while ( parent && parent != elem ) try { parent = parent.parentNode } catch(error) { parent = elem; };
+ while ( parent && parent != elem ) try { parent = parent.parentNode; } catch(error) { parent = elem; }
// Return true if we actually just moused on to a sub-element
return parent == elem;
};
Oops, something went wrong.

0 comments on commit 296cee5

Please sign in to comment.