Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 923877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:15:42+00:00 2026-05-15T19:15:42+00:00

Mootools : How to Allow and Disallow var drag depending on checkbox checked or

  • 0

Mootools: How to Allow and Disallow var drag depending on checkbox checked or not?

window.addEvent('domready',function() {
  var z = 2;
  $$('#dragable').each(function(e) {
    var drag = new Drag.Move(e,{
      grid: false,
      preventDefault: true,
      onStart: function() {
        e.setStyle('z-index',z++);
      }
    });
  });
});
function check(tag){
  if(tag.checked){
    //checkbox checked
    //How to Disallow Drag.Move for #dragable ?
    //Unfortunately so it does not work - drag.destroy(); drag.removeEvents();
  }else{
    //How to Allow Drag.Move for #dragable ?
  }
}
<input type="checkbox" onClick="check(this);">
<div id="dragable">Drag-able DIV</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:15:43+00:00Added an answer on May 15, 2026 at 7:15 pm

    Store the instance of Drag in MooTools Element Store so when the checkbox is clicked, we can retrieve this instance and manipulate it.

    Drag.Move is an extension to the base Drag class, and if you see the docs, you will notice it has two methods for this situation:

    • attach
    • detach

    You need to call these methods on the drag object that gets created when you call new Drag.Move(..) to enable or disable dragging.

    So first create the drag object as you are already doing:

    var drag = new Drag.Move(e, {
        ...
    });
    

    And then store a reference of this drag object inside the Element Store for later retrieval.

    e.store('Drag', drag);
    

    You can use any key you want here – I’ve used "Drag".

    Then later in the check function, retrieve the drag object, and call attach or detach on it depending on the state of the checkbox.

    function check(elem) {
        var drag = elem.retrieve('Drag'); // retrieve the instance we stored before
    
        if(elem.checked) {
            drag.detach(); // disable dragging
        }
        else {
            drag.attach(); // enable dragging
        }
    }
    

    See your example modified to work this the checkbox.

    On a side note, if you are retrieving an element by id, you don’t need to use $$ as ideally there should only be only element with that id. $$("#dragable") is just too redundant and less performant. Use document.id('dragable') or $("dragable") instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Mootools : How to get morpha.start() after 2sec mouseenter ? window.addEvent('domready',function() { var morph
Following is my JavaScript (mootools) code: $('orderNowForm').addEvent('submit', function (event) { event.preventDefault(); allFilled = false;
In mootools I would do something like $('form_id').send({success:function(res){....}}); What is the parallel syntax in
This is MooTools code: var myString = {subject} is {property_1} and {property_2}.; var myObject
In Mootools, the value of the this variable within a function can be controlled:
Mootools extends the Function class and adds a new method called extend in it.
Mootools Ajax class has a onComplete parameter whereby you can pass a function name
using mootools, and have the follwoing test. the test has an initial function that
I'm using mooTools and I need to call function TestA() on click event on
With Mootools, if I attach a change event listener on a <select> how do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.