⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

trigger('liszt:updated') Not Working on Multi select



bob
  • profile picture
  • Member

Posted 29 May 2013 - 19:15 PM

I am updating my multi-select with an Ajax request. The new option exists but when I call

$('#field-participants').trigger('liszt:updated');

after the option is added it doesn't refresh the select.

Any ideas?

 

Otherwise I want to say a big thanks to the author for this awesome tool. It has saved me a lot of time in this project.


victor
  • profile picture
  • Member

Posted 29 May 2013 - 20:37 PM

show your js code

bob
  • profile picture
  • Member

Posted 29 May 2013 - 22:00 PM

updateParticipants: function(data) {
        var $select = $('#field-participants');
        $select.append(
        $('<option></option>')
        .val(data.value)
        .html(data.name));
        $('#field-participants').trigger('liszt:updated');
    }

The above function is called on success of this ajax request:

$.ajax({
           url: base_url + 'index.php/timeline/update_table',
           type: 'post',
           data: {newVal : newVal, field:field },
           success: function(response) {
            var responseData = $.parseJSON(response);
                    self.updateParticipants(responseData);
//some code was removed here as sometimes another method is called depending on the field returned
           }
        });

As mentioned in the first post I can confirm the data is returned and the Dom is updated with the new select option. It is only at this point

$('#field-participants').trigger('liszt:updated');

that nothing happens. Also I want to confirm that this refresh does work on single selects


victor
  • profile picture
  • Member

Posted 29 May 2013 - 22:27 PM

what error do you get in the debugging panel?

By the way there are libraries on this forum which help to use dependents dropdowns


victor
  • profile picture
  • Member

Posted 29 May 2013 - 22:32 PM

this is my library: 

/topic/1087-updated-24112012-dependent-dropdown-library/

 

and Ricardomduarte's library:

/topic/1561-simple-dependant-dropdown-extension/

I have not used it but it's looks very good


bob
  • profile picture
  • Member

Posted 29 May 2013 - 22:44 PM

Victor thanks for you thoughts. I am not really in need of a dependent dropdown as such.

I really just need the chosen jquery plugin to work as it is documented for multi selects. It is fine for the single.

I probably should be asking there but there is no forum. Great jquery plugin that I only found through grocery crud.


victor
  • profile picture
  • Member

Posted 29 May 2013 - 23:00 PM

it's strangely...

but i don't like your function:

updateParticipants: function(data) {
var $select = $('#field-participants');
$select.append(
$('<option></option>')
.val(data.value)
.html(data.name));
$('#field-participants').trigger('liszt:updated');
}

I think this is more right, but I don't know what data do you get:

updateParticipants: function(data) {

var $select = $('#field-participants');
$.each(data, function(key, val) {
$select.append($('<option></option>').val(val.value).html(val.property));
});

$('#field-participants').trigger('liszt:updated');

}

P.S. Sorry buddy, I have to go to bed. My brain isn't working now. it's too late .


bob
  • profile picture
  • Member

Posted 29 May 2013 - 23:23 PM

By the way no errors shown in firebug.

Also I am returning an object like:

 

Object { name="John Smith", value=29, selectField="people_id"}

 

There is only ever one returned as it is an option to add one name to the select at a time.

I checked your site. Like the transitions between your pages.


Julio
  • profile picture
  • Member

Posted 17 June 2013 - 21:43 PM

Hi, bob!

 

Did you make it work out?

 

Please, could you give more details?

 

Thanks.