Can anyone tell me how to pass the draggable function as a parameter for clickit, which is an AJAX function? I want to pass draggable as a parameter to attach it to a dynamically added element. I can't get it to work defining the draggable function and pass it to clickit.
function clickit(fun){
$.ajax({
'url' : "url",
'dataType' : 'json',
'success' : function(data){
var item_html ="";
$.each(data.query.results.json,function(i,k){
item_html += '<div class="dialog"><h3>'+k+'</h3></div>'
});
$('.area').html(item_html);
fun;
}
});
}
$('button').click(function(){
var funpara = $('.dialog').draggable();
clickit(funpara)
});
Here's the one that works:
function clickit(){
$.ajax({
'url' : "url",
'dataType' : 'json',
'success' : function(data){
var item_html ="";
$.each(data.query.results.json,function(i,k){
item_html += '<div class="dialog"><h3>'+k+'</h3></div>'
});
$('.area').html(item_html);
$('.dialog').draggable();
}
});
}
$('button').click(function(){
clickit()
});
It looks like the parameter fun cannot be passed to the success function.