|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| 08/26/2009 at 10:14AM PDT, ID: 24683919 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>TITLE</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<cfajaxproxy cfc="reorder" jsclassname="myProxy">
<link type="text/css" href="admin/css/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
<script type="text/javascript" src="admin/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="admin/js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript">
// this creates an instance of the js proxy to cfc which we created with cfajaxproxy //
var p = new myProxy();
// this jQuery function executes after page DOM is loaded
$(document).ready(function(){
$("ul.items").disableSelection(); // this disables selection of item name text. not necessary, but a nice touch when you use Sortable
var $items = $("ul.menuitems"); // this is jQuery object of our items' container
initSortablesArray($items, 'li', '#tabs', 'y', 'updateItemsOrder'); //initialize Sortable for our items container
});
// this function creates the Sortable for items
var initSortablesArray = function($arrEl, sortItems, sortContainer, sortAxis, fnCallback) {
$arrEl.each(function() {
var $el = $(this);
$el.sortable({
items: sortItems, // element to be dragged, <li> in this example
containment: sortContainer, // element dragging is contained to, div id="tabs" in this example
axis: sortAxis, // axis to allow dragging along, Y in this example
update: function(event, ui){ // this function fires after an item changes its position/order after drag
var arrOrder = $el.sortable('toArray'); //serialize the items into array
console.log(arrOrder); //debug: will display the serialized array of item in Firebug console - remove when everything is working
var fnToExecute = fnCallback+"('"+arrOrder+"')";
setTimeout(fnToExecute, 0); //execute callback fucntion (updateItemsOrder in this example)
}
});
});
};
/*
this function is called on update event in Sortable list.
i use cfajaxproxy to create a js proxy to a remote cfc function which updates the items order in the db.
see the CFC section above for the function code.
*/
var updateItemsOrder = function(arrOrder) {
p.setCallbackHandler(updateOrderCB); //js function to execute after items order is updated in db
p.setErrorHandler(jsProxyError);//js function to execute on cfc/proxy error
p.updateOrder(arrOrder);// cfc function to execute
};
//success handler
var updateOrderCB = function(result) {
if(result) {
alert("Items order updated!");//change to whatever you want to do after items order has been updated
} else {
jsProxyError('n/a', 'Could not update items order...');// change to whatever else you want to do on error in updating items order
}
};
// error handler
var jsProxyError = function(code, msg) {
alert("ERROR: "+msg+" (err code: "+code+")");//change to whatever you do to show errors
};
</script>
</head>
<body>
<!--- QUERY DATABASE TO RETRIEVE PHOTOS //--->
<cfquery datasource="#application.datasource#" name="get_photos">
SELECT *
FROM photos
WHERE category = 'men' AND request_ID = #URL.ID#
ORDER BY priority ASC
</cfquery>
<!--- QUERY DATABASE TO RETRIEVE PHOTOS //--->
<cfset i = 1>
<cfset p = 1>
<h1>RE-ORDER ITEMS</h1>
<div id="tabs">
<ul class="items">
<cfoutput query="get_photos">
<li id="i_#ID#"><img src="photos/tn_#photo#" border="0"></li>
<cfset i = i + 1>
<cfif currentrow MOD 2 EQ 0>
<cfset p = p + 1>
</cfif>
</cfoutput>
</ul>
</div>
</body>
</html>
------------------------- BEGIN CONTENTS of reorder.cfc ----------------------
<cffunction name="updateOrder" access="remote" returntype="boolean" output="no">
<cfargument name="items_order" required="yes" type="any">
<cfscript>
var itemsorder = listtoarray(trim(arguments.items_order));// create local array from received list of element IDs
var qUpdateOrder = "";//create a local var for update query
var x = 0;// this local var will be the cfloop index, which is also the new ordinal of each item
var itemid = 0;//local var for item's id
var result = true;// function result
</cfscript>
<cfloop from="1" to="#arraylen(itemsorder)#" index="x">
<!--- our items in the page are <li> elements with unique IDs like i_#item_id#, thus to extract the item's id from received list of ordered items we need to parse each list element and get the part after _ - listlast() cf function makes it very easy. --->
<cfset itemid = listlast(trim(itemsorder[x]), "_")>
<cftry>
<cfquery name="qUpdateOrder" datasource="#application.datasource#">
UPDATE photos
SET priority = <cfqueryparam cfsqltype="cf_sql_smallint" value="#x#">
WHERE ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#itemid#">
</cfquery>
<cfcatch>
<cfset result = false>
</cfcatch>
</cftry>
</cfloop>
<cfreturn result />
</cffunction>
|
Advertisement