glennn.php Posted March 4, 2012 Share Posted March 4, 2012 regarding this script: http://cssphpmysql.com/dev/my-lifeline/ this is a script for shuffling these blocks like on iGoogle fires a few php/mysql UPDATE queries whenever a block is dragged/dropped from column to column, but fails to fire the queries if a block is dragged to a dif. position within the same column - i'm failry noob with jquery/javascript and after a lot of hunting and pecking i'm unable to find why. here's a bit of the code which i think is pertinent, though not sure. i would be very grateful if someone could offer a little help? i can post more code if this doesn't tell much... Portal.prototype = { initialize : function (settings, options, data) { // set options this.setOptions(options); // set blocks to their positions this.apply_settings(settings); // load data to blocks //this.loadData(data); // if editor is enabled we proceed if (!this.options.editorEnabled) return; // get all available columns var columns = $(this.options.portal).getElementsByClassName(this.options.column); // loop through columns array $A(columns).each(function(column) { // create sortable Sortable.create(column, { containment : $A(columns), constraint : this.options.constraint, ghosting : this.options.ghosting, tag : this.options.tag, only : this.options.block, dropOnEmpty : this.options.droponempty, handle : this.options.handle, hoverclass : this.options.hoverclass, scroll : this.options.scroll, onUpdate : function (container) { // if we dont have a save url we dont update if (!this.options.saveurl) return; // if we are in the same container we do nothing if (container.id == this.options.blocklist) return; // get blocks in this container var blocks = container.getElementsByClassName(this.options.block); // serialize all blocks in this container var postBody = container.id + ':'; postBody += $A(blocks).pluck('id').join(','); postBody = 'value=' + escape(postBody); // save it to the database new Ajax.Request(this.options.saveurl, { method: 'post', postBody: postBody, onComplete : function (t) { $('data').update(t.responseText + $('data').innerHTML); } }); }.bind(this) }); }.bind(this)); }, apply_settings : function (settings) { // apply settings to the array for (var container in settings) { settings[container].each(function (block) { if (!$(container)) { console.log('Block '+container+' not found') } else { $(container).appendChild($(block)); } }); } }, setOptions : function (options) { // set options this.options = { tag : 'div', editorEnabled : false, portal : 'portal', column : 'column', block : 'block', blocks : 'blocks', content : 'content', configElement : 'config', configSave : 'save-button', configCancel : 'cancel-button', configSaved : 'config-saved', handle : 'draghandle', hoverclass : 'target', scroll : window, remove : 'option-remove', config : 'option-edit', blocklist : 'portal-column-block-list', saveurl : true, constraint : false, ghosting : false, droponempty : true } Object.extend(this.options, options || {}); }, the HTML: <div id="columns"> <div id="column-1" class="column menu"></div> <div id="column-2" class="column blocks"></div> <div id="column-3" class="column sidebar"></div> <div class="portal-column" id="portal-column-block-list" style="display: none;"> // example block <div class="block" id="block-1"> <h1 class="draghandle"><span id="title-1" class="editText">1977</span></h1> <p><span id="evnt-1" class="editText">Berry Academy</span></p> </div> </div> </div> i've attached a dragdrop.js file as a txt file. I'll be very grateful for any offer of help. thanks loads. GN 17687_.txt Quote Link to comment https://forums.phpfreaks.com/topic/258227-3-columns-dragdrop-blocks-not-persistent-within-same-column/ Share on other sites More sharing options...
S3cr3t Posted March 4, 2012 Share Posted March 4, 2012 Did you define the saveUrl ? saveurl : true, Should be a valid .php file that accepts the request. Quote Link to comment https://forums.phpfreaks.com/topic/258227-3-columns-dragdrop-blocks-not-persistent-within-same-column/#findComment-1323732 Share on other sites More sharing options...
glennn.php Posted March 4, 2012 Author Share Posted March 4, 2012 yes, it's actually defined in the index.php file: <script type="text/javascript"> var settings = {<?=getBlocks()?>}; var options = { portal : 'columns', editorEnabled : true, saveurl : 'save.php' }; var data = {}; var portal; Event.observe(window, 'load', function() { portal = new Portal(settings, options, data); }); </script> remember, what's happening is that the script performs properly when a block is moved from column to column, only not when a block is moved WITHIN the column. i REALLY appreciate your help. and i'm glad to show you more of the js if necessary... Quote Link to comment https://forums.phpfreaks.com/topic/258227-3-columns-dragdrop-blocks-not-persistent-within-same-column/#findComment-1323733 Share on other sites More sharing options...
S3cr3t Posted March 4, 2012 Share Posted March 4, 2012 Unfortunately I don't know that script. Got something in the JS error console ? PHP errors ? Tried do compare your script with that one in the demo ? Quote Link to comment https://forums.phpfreaks.com/topic/258227-3-columns-dragdrop-blocks-not-persistent-within-same-column/#findComment-1323738 Share on other sites More sharing options...
glennn.php Posted March 4, 2012 Author Share Posted March 4, 2012 oh, by being persistent, what i mean is that it writes to the database - if you drag a block to another column and refresh your page, it's persistent - if you drag a block within its own column to a different position it won't write to the database, and when you refresh the page it's back to where it was. if you drag a block from one column to the another and then BACK to its orig. column in a different position it will have written to the db both times and it's all good... Quote Link to comment https://forums.phpfreaks.com/topic/258227-3-columns-dragdrop-blocks-not-persistent-within-same-column/#findComment-1323739 Share on other sites More sharing options...
glennn.php Posted March 4, 2012 Author Share Posted March 4, 2012 Unfortunately I don't know that script. Got something in the JS error console ? PHP errors ? Tried do compare your script with that one in the demo ? the link (demo) i sent you is my script - i hardly modified the js at all, but the original script doesn't work right, either. can i send you the original? it's really small - i'd even be glad to make a nice donation if you could improve this particular 'bug'... Quote Link to comment https://forums.phpfreaks.com/topic/258227-3-columns-dragdrop-blocks-not-persistent-within-same-column/#findComment-1323740 Share on other sites More sharing options...
glennn.php Posted March 4, 2012 Author Share Posted March 4, 2012 i've attached the original script for anyone who'd care to take a peek. donations pending... : ) 17689_.zip Quote Link to comment https://forums.phpfreaks.com/topic/258227-3-columns-dragdrop-blocks-not-persistent-within-same-column/#findComment-1323741 Share on other sites More sharing options...
S3cr3t Posted March 4, 2012 Share Posted March 4, 2012 Well this script isn't really supposed to update boxes in same container... Quote Link to comment https://forums.phpfreaks.com/topic/258227-3-columns-dragdrop-blocks-not-persistent-within-same-column/#findComment-1323751 Share on other sites More sharing options...
glennn.php Posted March 4, 2012 Author Share Posted March 4, 2012 can it not be made to do so? i'm paying... Quote Link to comment https://forums.phpfreaks.com/topic/258227-3-columns-dragdrop-blocks-not-persistent-within-same-column/#findComment-1323752 Share on other sites More sharing options...
glennn.php Posted March 4, 2012 Author Share Posted March 4, 2012 Well this script isn't really supposed to update boxes in same container... feel free to PM me if it's something you'd consider "arranging"... Quote Link to comment https://forums.phpfreaks.com/topic/258227-3-columns-dragdrop-blocks-not-persistent-within-same-column/#findComment-1323758 Share on other sites More sharing options...
S3cr3t Posted March 4, 2012 Share Posted March 4, 2012 Or you just drag them first to the left / right and then in the middle. Quote Link to comment https://forums.phpfreaks.com/topic/258227-3-columns-dragdrop-blocks-not-persistent-within-same-column/#findComment-1323760 Share on other sites More sharing options...
glennn.php Posted March 4, 2012 Author Share Posted March 4, 2012 Or you just drag them first to the left / right and then in the middle. Or you just drag them first to the left / right and then in the middle. yes, well that's exactly what i'm trying to NOT have to do. thanks, tho. Quote Link to comment https://forums.phpfreaks.com/topic/258227-3-columns-dragdrop-blocks-not-persistent-within-same-column/#findComment-1323763 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.