

Bridge jQuery UI droppable for Lift ajax handler
source link: https://www.codesd.com/item/bridge-jquery-ui-droppable-for-lift-ajax-handler.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Bridge jQuery UI droppable for Lift ajax handler
I'm working on a web application project using Scala / Lift. I would like to make my application support drag and drop to improve the user experience.
But I'm not quite sure how to bridge jQuery part with Lift.
Currently I've a working UI part, an div block has class named listRow
is dragable with an HTML5 attribute data-stuffid
which has an ID from database.
It can be dragged to an block named nextAction
, and I could print out the data-stuffid
field correctly in JavaScript.
Here is my JavaScript code block:
<script type="text/javascript">
$('.listRow').draggable({
revert: true
});
$("#nextAction").droppable({
accept: ".listRow",
tolerance: "pointer",
activeClass: "dropActive",
hoverClass: "dropHover",
drop: function(event, ui) {
var stuffID = ui.draggable.data("stuffid")
console.log(stuffID)
}
})
But I don't know how to call to a Lift AJAX handler, and pass stuffID to Lift in the case.
What I would like to do is have an Scala function likes the following:
def showDialog(stuffID: String): JsCmds
{
// Do some server side work, ex: querying database
// Return a javascript cmds likes SHtml.ajaxButton...etc.
Alert("SutffID:" + stuffID)
}
And when user drag a .listRow
to "#nextAction", showDialog
would be called, and return the javascript to browser and let browser execute it.
You probably looking for one of these two functions. I'd take a look at :
JsCmds.Function
and SHtml.ajaxCall
JsCmds.Function
will allow you to create a JavaScript function, and SHtml.ajaxCall
will allow you to execute code via ajax. You'd create a function in your Lift CSS Selector and then you'd be able to call that functions directly from your jQuery code.
There are a lot of discussions on using both those, some relevant info might be:
Recommend
-
52
A javascript library to give file dropping super-powers to any HTML element.
-
12
Ajax promises without jQuery I originally posted on GeeksWithBlogs.net on 10/07/2014. I decided to port it here, after getting another up-vote on
-
20
Dynamic Dependent Select Box using jQuery, Ajax and PHP The dynamic dependent select box is used to auto-populate the dependent data in the dropdown list. Bases on the drop-down selection, the dependent dat...
-
8
Home » How To Guides » Ajax » How to Get File Upload Progress in Ajax using jQ...
-
14
jQuery ajax 方法 data 参数默认 encode 失败的 bugkeelii公众号「肆零玖陆」 — 以程序员的视角谈天说地
-
8
Introduction jQuery can be paired with form submission to handle validation. This has the benefit of providing users with feedback on any errors in their input.
-
6
Ajax with jquery does not work advertisements In view page: <script languge="javascript" type="text/javascr...
-
5
Input Validation with PHP and Jquery Ajax advertisements I want to validate an user input with ajax. It is the first time I use Ajax and I got stuc...
-
7
How to call https url ajax request in javascript or jquery advertisements Can anybody tell How to call https url ajax request in java script o...
-
7
How to Remove an Event Handler in jQuery 1177 views 2 years ago jQuery Use the jQuery off() Me...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK