{"id":8000,"date":"2015-11-17T00:16:45","date_gmt":"2015-11-17T00:16:45","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/17\/moving-an-item-programmatically-with-jquery-sortable-while-still-triggering-events-open-source-projects-rubaxa-sortable\/"},"modified":"2022-08-30T15:03:04","modified_gmt":"2022-08-30T15:03:04","slug":"moving-an-item-programmatically-with-jquery-sortable-while-still-triggering-events-open-source-projects-rubaxa-sortable","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/17\/moving-an-item-programmatically-with-jquery-sortable-while-still-triggering-events-open-source-projects-rubaxa-sortable\/","title":{"rendered":"Moving an item programmatically with jQuery sortable while still triggering events-open source projects RubaXa\/Sortable"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c02f1985a661e6099adaad3f8dd94195?s=128&amp;d=identicon&amp;r=PG\" \/> <strong>flu<\/strong><\/p>\n<p>As each <em>event callback<\/em> is defined as an <em>option<\/em> of the sortable widget it can be retrieved as such by calling the option method for the corresponding <em>event callback option<\/em> (this example uses the <code>update<\/code> callback):<\/p>\n<pre><code>$('#plan').sortable({\n  update: function(event, ui) {\n    \/\/ Do something...\n  }\n});\n\n$('#plan').sortable('option', 'update'); \/\/ returns function\n<\/code><\/pre>\n<p>The update callback expects two parameters, the <code>event<\/code> and a <code>ui object<\/code>. The <code>event<\/code> can be set to null and the <code>ui object<\/code> needs to be defined with all the properties your <code>update callback<\/code> expects:<\/p>\n<pre><code>$('#plan').sortable('option','update')(\n  null,\n  {\n    item: $('<\/code><\/pre>\n<li><code>new item<\/code><\/li>\n<pre>').appendTo($('#plan'))\n  }\n);\n<\/pre>\n<p><code>This works for all event callbacks that you defined (i.e. <code>receive<\/code>, <code>change<\/code> etc.).<\/code><\/p>\n<p>Working JS-Fiddle<\/p>\n","protected":false},"excerpt":{"rendered":"<p>flu As each event callback is defined as an option of the sortable widget it can be retrieved as such by calling the option method for the corresponding event callback option (this example uses the update callback): $(&#8216;#plan&#8217;).sortable({ update: function(event, ui) { \/\/ Do something&#8230; } }); $(&#8216;#plan&#8217;).sortable(&#8216;option&#8217;, &#8216;update&#8217;); \/\/ returns function The update callback [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8000","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8000","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=8000"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8000\/revisions"}],"predecessor-version":[{"id":8710,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8000\/revisions\/8710"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=8000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=8000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=8000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}