/* Set focus, and place the cursor at the end of the input string */
dojo.addOnLoad(function() {
- dijit.byId('search_box').focus();
- [%- END %]
-
- var sb_elem = dijit.byId('search_box');
- var sb_value;
+ /* Don't error out if the object doesn't exist, like on advanced search pages */
+ [%- IF basic_search != "f"; %]
+ if (dojo.byId('search_box')) {
+ dijit.byId('search_box').focus();
- if (sb_elem) {
- sb_value = sb_elem.value;
- }
- /* Dojo won't trigger a change if the value doesn't change */
- if (sb_value) {
- dijit.byId('search_box').setValue(sb_value + ' ');
- dijit.byId('search_box').setValue(sb_value);
+ var sb_value = dijit.byId('search_box').value;
+ /* Dojo won't trigger a change if the value doesn't change */
+ if (sb_value) {
+ dijit.byId('search_box').setValue(sb_value + ' ');
+ dijit.byId('search_box').setValue(sb_value);
+ }
}
++ [%- END %]
});
</script>
[% END; # use_autosuggest %]