Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

jQuery .live

Posted on 2011-03-22
6
Medium Priority
?
457 Views
Last Modified: 2013-11-11
Hello,

i was wondering if there is a way to  assign sortable to $( "#canvas .widget" ) using live method or such ?
$( "#canvas .widget" ).sortable();

Open in new window


Obviously something like this wont work. $( "#canvas .widget" ).live('sortable', function(){});

Any idea ?
0
Comment
Question by:sahanz
  • 3
  • 3
6 Comments
 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 2000 total points
ID: 35196133
@sahanz: live method is used to event handler binding, much like bind() method only difference being that in live() binding, the event will be attached even if the current selector is available now.

So i need to know why do you want to use the live method. Or precisely, what is the requirement?
0
 
LVL 1

Author Comment

by:sahanz
ID: 35196151
Hi there.

I have this div

<div id="canvas">

</div>

from an ajax call I load some divs in to this #canvas and those are having a class called "widget"

so after getting these div.widget s I want them to be sortable.
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 35196156
you need to make it sortable every time the ajax load finishes
check this explanation
http://stackoverflow.com/questions/4323639/jquery-live-and-sortable
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:sahanz
ID: 35196165
That's what I thought, the ajax call actually append to #canvas and the ajax load works few times, so that means on each load I have to do the sortable right?
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 35196169
yes
0
 
LVL 1

Author Closing Comment

by:sahanz
ID: 35196216
Thank you.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question