Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var box = [];
- var $container = $("#container");
- /** DragBox Init */
- function DragBox(url, controller) {
- this.url = url;
- this.htmlcontent = "";
- this.controller = controller;
- this.test = "null";
- this.requestContent = function() {
- $.get(this.url, null, function(res) {
- $container.append(res);
- });
- }
- this.requestContent();
- $(this).attr("id", this.controller);
- $("#" + this.controller).hide().fadeIn(1000).draggable();
- }
- var links = $("li a");
- for(var i = 0; i < links.length; i++) {
- links[i].onclick = function() {
- box.push(new DragBox($(this).attr("href"), $(this).attr("controller")));
- return false;
- }
- }
- function DragBox(url) {
- // init stuff...
- this.requestContent = function(callback) {
- $.get(url, function(res) {
- var $element = $(res);
- $element.appendTo($container);
- $element.hide();
- // The job is done, execute the code inside callback
- callback($element);
- });
- }
- // Render the requested html content and make it draggable
- this.requestContent(function($element) {
- $element.fadeIn(1000).draggable();
- });
- }
- $(document).on('click', 'li a', function(e) {
- if ( /* some condition */ ) {
- var some_var = new DragBox(params);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement