').addClass('description').text(description));
+ }},
+ empty: $('
').addClass('empty-suggestion').text('No matches found')
}}
}}
- ).on('typeahead:select', function(ev, suggestion) {{
- console.log('[JS] Selection event received');
+ )
+ .on('typeahead:asyncreceive', function(ev, dataset, suggestions) {{
+ console.log('[JS] Received suggestions:', suggestions);
+ if (suggestions && suggestions.length > 0) {{
+ $(this).data('ttTypeahead').dropdown.open();
+ }}
+ }})
+ .on('typeahead:select', function(ev, suggestion) {{
+ console.log('[JS] Selection data:', JSON.stringify(suggestion, null, 2));
window['{handler}'](ev, suggestion);
}});
- console.log('[JS] Typeahead initialized successfully');
}} catch (e) {{
console.error('[JS] Typeahead init error:', e);
}}
"#,
id = input_id,
- handler = handler_name.replace('-', "_") // Replace hyphens to avoid JS issues
+ handler = handler_name.replace('-', "_")
);
log!("[RUST] Initialization script: {}", init_script);
if let Err(e) = js_sys::eval(&init_script) {
log!("[RUST] Eval error: {:?}", e);
}
-}
\ No newline at end of file
+}