A used your sugestion by Han to solve my problem, but because of
problem of "undefined" don't works for me, then I tried done by other
way as not add one item at result list. I create a function
"noSelection".

I used the 3 firsts steps that they used.

the 4th step I rewrote as

if(!config.mouseDownOnSelect) {
 hideresults();
 if (selectionMade == 0) {
   $input.trigger("noSelection"); // This Line Changed
 }

}

and I need "instance" de function noSelection to it works I need add
this at line 39.

  result: function(handler) {
      return this.bind("result", handler);
  },

  noSelection: function(handler) {
      return this.bind("noSelection", handler);
  },

  search: function(handler) {
      return this.trigger("search", [handler]);
  },


and to finally I personalize for each autocomplete that I have on my
page.

$("#name").autocomplete('seatch.php');

$("#id").result(function(event, data, formatted) {
  $("#id").val(data[1]);
 }

$("#id").noSelection(function() {
  $("#id").val(""); // Clear the input hidden
 }

My code where I call the autocomplete is a little diferent of this
above, but I think work as same. see how was my code.

  $(function() {
      $("#txtSomeone").autocomplete('ajax.aspx', {
          multiple: false,
          minChars: 2,
          parse: function(data) {
              return $.map(eval(data), function(row) {
                  return {
                      data: row,
                      value: row.texto,
                      result: row.texto
                  }
              });
          },
          formatItem: function(item) {
              return format(item);
          }
      }).result(function(e, item) {
          $("#hiddenOfSomeone").val(item.codigo);
      })
      .noSelection(function(){
         $("#hiddenOfSomeone").val("");
      }) ;

  });


[ ],s

sorry for my English ;)

Wellington Rodrigues


On 1 mar, 11:08, Paul Noden <nods...@gmail.com> wrote:
> Hi Brian,
>
> How did you get on with adding checkbox support to jeditable, it would
> be nice to have jeditable support all input types such as checkboxes
> and radio buttons (the ok/cancel would need to be for the entire named
> group) and of course password, and file. jeditable is pretty great as
> it stands, but with a more rounded support it makes things that little
> bit quicker.
>
> I've yet to test this comprehensively, but I've written a very quick
> proof of concept to allow the callback function make changes to the
> value returned. This allows your callback function to intercept the
> response from the server and process any validation messages you might
> want to alert the user to.
>
> On the simplest level:
>
>  var callback = settings.callback || function() { };
> becomes
>  var callback = settings.callback || function(value, settings)
> { return value; };
>
> callback.apply(self, [self.innerHTML, settings]);
> becomes
> $(self).html(callback.apply(self, [self.innerHTML, settings]));
>
> This allows you to then use a callback to provide validation
> responses, such as "edit unsaved, 'value' already exists" and then
> return the control to it's original value or as desired...
>
> As a quick example your server response might be "%%original value%%
> [edit unsaved, '%%new value%%' already exists]" for a failure and "%
> %new value%%" for a success together with a callback like the
> following:
>
> callback :function(value, settings) {
>                   if(value.indexOf('[')>=0){
>                                 
> alert(value.substring(value.indexOf('[')+1,value.indexOf(']')));
>                                 return value.substring(0,value.indexOf('['));
>                 }else{
>                         return value;
>                 }
>      }
>
> of course you can put your validation message into an element on the
> page rather than alert the message... Hopefully this illustrates the
> power of a proper callback function and will see the idea develop
> within the plugin.
>
> Paul

Reply via email to