terça-feira, 23 de outubro de 2012

jQuery Autocomplete: submeter formulário ao selecionar opção

Usando o plugin de auto completar do jQuery, você talvez deseje aplicar uma técnica de usabilidade interessante. Ao clicar em uma das opções sugeridas pelo plugin, o formulário vai ser submetido automaticamente com o termo selecionado.

Segue o código:

$i(".search-field").autocomplete({
     source : listaQualquer,
     select: function (event, ui) {
         $i('.search-field').val($i(event.target).val(ui.item.value).val());
         $i('.search-button').click();
     }

});

O truque é bem simplório, basta pegar o valor selecionado, setar no campo da busca e ativar o evento click() do botão.

quinta-feira, 18 de outubro de 2012

sexta-feira, 11 de novembro de 2011

Fixing mkmf load error on Ubuntu 11.11 Oneiric Ocelot

Last week I have a problem with the webbynode gem, needed to WebbyNode VPS easy deploy feature.

When I ran the gem, I get this error:

Building native extensions. This could take a while…
ERROR: Error installing hpricot:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:1:in `require’: no such file to load — mkmf (LoadError)
from extconf.rb:1


I deeply seached about the problem, and this solution seemed to resolve for everyone but me.

With the help of the support and the official RubyGems site, I found the solution for my nightmare case.

Let's begin. The main objective was to update the webbynode gem version. For this, firstly I need to update the RubyGem itself.

cassio@cassio-note:~$ sudo gem update --system

ERROR:  While executing gem ... (RuntimeError)
    gem update --system is disabled on Debian, because it will overwrite the content of the rubygems Debian package, and might break your Debian system in subtle ways. The Debian-supported way to update rubygems is through apt-get, using Debian official repositories.
If you really know what you are doing, you can still update rubygems by setting the REALLY_GEM_UPDATE_SYSTEM environment variable, but please remember that this is completely unsupported by Debian.


This command line is not supported by Debian based systems like Ubuntu. So, the official site tell us to use an updater gem. Maybe you will not need to update your gem.

cassio@cassio-note:~$ sudo gem install rubygems-update

Successfully installed rubygems-update-1.8.11
1 gem installed
Installing ri documentation for rubygems-update-1.8.11...
Installing RDoc documentation for rubygems-update-1.8.11...


cassio@cassio-note:~$ sudo update_rubygems 

RubyGems 1.8.11 installed
== 1.8.11 / 2011-10-03
* Bug fix:
  * Deprecate was moved to Gem::Deprecate to stop polluting the top-level
    namespace.


------------------------------------------------------------------------------



RubyGems installed the following executables:
    /usr/bin/gem1.9.1

Maybe you will need to run apt-get install libsqlite3.0 (on Ubuntu)

Now, get the gem that I need:
cassio@cassio-note:~$ sudo gem install --pre webbynode


Before update gem this command showed this sick error:


ERROR: While executing gem ... (NameError)
uninitialized constant Syck::Syck