javascript - Inputosaurus Text + jQuery UI Sortable -
i'm trying combine inputosaurus text jquery-ui sortable plugin can re-order tags , submit them in order.
attaching sortable inputosaurus list works fine, can move tags around. need way inputosaurus detect they've moved. if submit form after moving tags, submitted in original order.
here simple demonstration of i'm trying accomplish, need textbox have updated value of list
html:
<input type="text" id="tags" name="tags" value="foo,bar,baz">
javascript:
$('#tags').inputosaurus(); $(".inputosaurus-container").sortable({ update: function( event, ui ) { alert( $('#tags').val() ); } });
http://jsfiddle.net/75c45jtn/1/
if me solve you'd hero!
it may help. try this..
$(".inputosaurus-container").sortable({ update: function( event, ui ) { var val="",obj=null; var cnt=$('.inputosaurus-container').children('li').length-2; while(cnt>0){ if(cnt!=3){ val+=','; val+=obj.next().find('span').text(); obj=obj.next(); } else{ val+=$('.inputosaurus-container').children('li').first().find('span').text(); obj=$('.inputosaurus-container').children('li').first(); } cnt--; } $('.inputosaurus-container').find('.inputosaurus-input-hidden').find('input').val(val); alert($('.inputosaurus-container').find('.inputosaurus-input-hidden').find('input').val()); $('.inputosaurus-container').find('.inputosaurus-input-hidden').find('input').inputosaurus(); } });
i'm not 100% sure
Comments
Post a Comment