javascript - Why can't jQuery UI sortable elements be dragged from a handle? -


i have page add fields fake form user can @ before generating source.

i'm trying give user ability sort , order fields inside form. use jquery ajax , animations, decided use jquery ui sorting.

my fields added dinamicly, delegate events, , use sortable('refresh'); every time new field added.

my gui has icons fields options, added handle option sortable() method, doesn't recognize @ all!

here demo of gui problem (it's in arabic , still in alpha no ie7-6 support, uses icons easy use ^^): http://mahersalam.co.cc/projects/namodgmaker/

just add field red buttons, , try drag drag button, doesn't work. if remove handle works perfectly!

you can see log handle value console, logs sortable object... there global object namodgmaker want experiment it.

here part adds fields , attach sortable() method:

addfield: function( type ) {      var $html = $(this.fields[type]); // 'this' here namodgmaker, , `fields` ajax request      if (type == 'select') {         $html             .find('select')                 .stylenamodgselects({                     optionsright: -6,                     optionstop: 38                 });     }      $html.appendto(this.formholder);      if ( this.formholder.data('sortable') ) {          this.formholder.sortable('refresh');         console.log( this.formholder.sortable( "option", "handle" ) );         return     }      this.formholder         .sortable({             containment: 'parent',             handle: '.drag-field-option'         })         .data('sortable', true)      console.log( this.formholder.sortable( "option", "handle" ) ); } 

this first time jquery ui, doing wrong?

update: found out $.data() causing sortable return wrong options. modified code use sortable()'s own checking method:

addfield: function( type ) {      var $html = $(this.fields[type]);      if (type == 'select') {         $html             .find('select')                 .stylenamodgselects({                     optionsright: -6,                     optionstop: 38                 });     }      $html.appendto(this.formholder);      if ( ! this.formholder.sortable( "option", "disabled")  ) {          this.formholder.sortable('refresh');         console.log( 'refreshed :' + this.formholder.sortable( "option", "handle" ) );         return     }      this.formholder         .sortable({             containment: 'parent',             handle: '.drag-field-option'         })       console.log( this.formholder.sortable( "option", "handle" ) ); } 

now console logs right selector still sorting functionality not working.

update 2: able solve problem changing handle element button a.

the fix change handle button a. seems jquery ui doesn't semantic markup!


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -