You need to sign in to do that
Don't have an account?

Drag and Drop using javascript
Hi guys,
I'm trying to get a pretty standard Scriptaculous drag and drop functionality using javascript to work in a visual force page. Am not having any great deal of luck right now. Can anyone help or point me in the right direction
below is the source for the drag and drop page I have done in HTML it works fine I want to try and port it to visual force, ultimately being able to use the output from the 'debug log button there' to use in a Controller Extension and create some relationships between objects.
I'm guessing the problem is with the way visual force pages reference ID's?? But I can't be completely sure. Any help would be great. Thanks :)
I'm trying to get a pretty standard Scriptaculous drag and drop functionality using javascript to work in a visual force page. Am not having any great deal of luck right now. Can anyone help or point me in the right direction
below is the source for the drag and drop page I have done in HTML it works fine I want to try and port it to visual force, ultimately being able to use the output from the 'debug log button there' to use in a Controller Extension and create some relationships between objects.
I'm guessing the problem is with the way visual force pages reference ID's?? But I can't be completely sure. Any help would be great. Thanks :)
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Drag Drop</title> <script src="http://script.aculo.us/prototype.js" type="text/javascript"></script> <script src="http://script.aculo.us/scriptaculous.js" type="text/javascript"></script> <script language="JavaScript"> sections = ['group1','group2','group3']; function createNewSection(name) { var name = $F('sectionName'); if (name != '') { var newDiv = Builder.node('div', {id: 'group' + (sections.length + 1), className: 'section', style: 'display:none;' }, [ Builder.node('h3', {className: 'handle'}, name) ]); sections.push(newDiv.id); $('page').appendChild(newDiv); Effect.Appear(newDiv.id); destroyLineItemSortables(); createLineItemSortables(); createGroupSortable(); } } function createLineItemSortables() { for(var i = 0; i < sections.length; i++) { Sortable.create(sections[i],{tag:'div',dropOnEmpty: true, containment: sections,only:'lineitem'}); } } function destroyLineItemSortables() { for(var i = 0; i < sections.length; i++) { Sortable.destroy(sections[i]); } } function createGroupSortable() { Sortable.create('page',{tag:'div',only:'section',handle:'handle'}); } /* Debug Functions for checking the group and item order */ function getGroupOrder() { var sections = document.getElementsByClassName('section'); var alerttext = ''; sections.each(function(section) { var sectionID = section.id; var order = Sortable.serialize(sectionID); alerttext += sectionID + ': ' + Sortable.sequence(section) + '\n'; }); alert(alerttext); return false; } </script> <style> body, div { font-family: Arial, Helvetica; font-size: 11px; } div.section,div#createNew { border: 1px solid #CCCCCC; margin: 30px 5px; padding: 0px 0px 10px 0px; background-color: #EFEFEF; } div#createNew input { margin-left: 5px; } div#createNew h3, div.section h3{ font-size: 14px; padding: 2px 5px; margin: 0 0 10px 0; background-color: #CCCCCC; display: block; } div.section h3 { cursor: move; } div.lineitem { margin: 3px 10px; padding: 2px; background-color: #FFFFFF; cursor: move; } h1 { margin-bottom: 0; font-size: 18px; } </style> </head> <body> <div id="page"> <div id="createNew"> <h3>Add New Sales Contact</h3> <input type="text" id="sectionName" size="25"> <input type="button" onClick="createNewSection();" value="Create Sales Contact"> </div> <div id="group1" class="section"> <h3 class="handle">Tickets</h3> <div id="item_1" class="lineitem">DWD2008 VIP</div> <div id="item_2" class="lineitem">DWD2008 GOLD</div> <div id="item_3" class="lineitem">DWD2008 SILVER</div> <div id="item_4" class="lineitem">DWD2008 BRONZE</div> </div> <div id="group2" class="section"> <h3 class="handle">Sales Contact 1</h3> </div> <div id="group3" class="section"> <h3 class="handle">Sales Contact 2</h3> </div> </div> <fieldset> <legend>group order debug</legend> <input type="button" onClick="getGroupOrder()" value="output group order"> <br> </fieldset> <script type="text/javascript"> // <![CDATA[ Sortable.create('group1',{tag:'div',dropOnEmpty: true, containment: sections,only:'lineitem'}); Sortable.create('group2',{tag:'div',dropOnEmpty: true, containment: sections,only:'lineitem'}); Sortable.create('group3',{tag:'div',dropOnEmpty: true, containment: sections,only:'lineitem'}); Sortable.create('page',{tag:'div',only:'section',handle:'handle'}); // ]]> </script> </body> </html>
Message Edited by dchasman on 06-23-2008 07:48 AM
Will we all have to purchase Ext.js licenses?
Hey guys still having a bit of trouble on this one. Main thing being that I want to pass my output string from the javascript function "GroupOrder();" to my controller or extension.... Is there anyway to do it?
I've seen something similar on the forums but couldn't quite get it working. Really would appreciate any help on this one it's driving me nuts!
In dreamweaver I can get this "groupOrder();" function to execute and give me a string of what elements have what children. But in Visual force everything seems to work fine except for this one **bleep** function :(.
Below is my code for my controller and my visual force page Thanks in advance to anyone that can crack this one. Right now I'm pulling values from SF and using <apex:repeater" tags to format them.. then I want to get the value that gets spat out from "groupOrder()" in the javascript and parse it to upsert some objects in salesforce. Obviously any other ideas on how to solve this would be great also.
Cheers,