[yast-devel] WebYast server side path completion
Hi, I think that might be useful for some modules to allows enhanced specify path of target machine. Usual java script browsing cannot be used, as it uses browser pc and not server pc. As base I use this script http://www.pengoworks.com/workshop/jquery/autocomplete.htm , but must disable caching and losing focus, as it doesn't work after submit first part of path (no hint on another parts). If you want try it, just add to public/javascript attached js file and to public/stylesheets attached css and gif. Additional you must define for some controller response: for path finding I use this: def pathcompl path = params[:q] if (path[0].chr != "/") path = "/"+path end dir = path[0..path.rindex("/")] pre = path[path.rindex("/")+1..path.size] result = `ls -1 '#{dir}' | sed "s:^\\(.\\+\\)$:#{dir}\\1:"| grep '#{dir}#{pre}'` render :text => result end How to use...fast way is add this to your RoR view (home_controller contain pathcompl method) and: <input type="text" id="autocomplete" name="autocomplete_parameter"/> <script type="text/javascript"> $("#autocomplete").autocomplete("home/pathcompl",{ cacheLength:1 }); </script> and to head of view: <script src="/javascripts/jquery.autocomplete.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="/stylesheets/jquery.autocomplete.css" /> What do you think about this enhancement? I welcome any comments as I am just learning AJAX, RoR and js. Josef
participants (1)
-
Josef Reidinger