Loading ...
Sorry, an error occurred while loading the content.

DragDropTarget.isTarget = false Does Not Completely Work

Expand Messages
  • john j
    I am trying to put a size limit on a DragDropTarget by setting its isTarget property to false whenever the size max is reached (implementation uses
    Message 1 of 3 , Jun 27, 2009
    • 0 Attachment
      I am trying to put a size limit on a DragDropTarget by setting its isTarget property to false whenever the size max is reached (implementation uses dragDropEvent). It works as hoped for when trying to add items to the *bottom* of the disabled list. However, when an item is drop-attempted anywhere else in the "disabled" list, the drop goes through w/o rejection. Any hints on how to fix this?

      Here's the pertinent code (groovy/js):

      <script>
      GRAILSUI.${jsid} = {
      init: function() {

      ${
      lists.collect { listItem ->
      def result = "new YAHOO.util.DDTarget('${listItem.key}');\n"
      listItem.value.each {
      result += "var ${it}_dli = new GRAILSUI.DraggableListItem('${it}');\n"
      result += "${it}_dli.on('dragDropEvent', this.onDragDropEvent);\n"
      }
      result
      }.join('')
      }
      this.populateHiddenInput();
      },

      onDragDropEvent: function() {
      var parseListToHiddenInput = function(ul, listName, listIndex) {
      var items = ul.getElementsByTagName("li");
      var out = "";
      for (i=0;i<items.length;i=i+1) {
      out += items[i].id + " ";
      }
      YAHOO.util.Dom.get(listName + '_input').value = out;
      ${
      if (attrs.maxSelect) {
      """
      if (listIndex == 0) {
      var selectTarget = this.DDM.ids.default[listName];
      if (items.length >= ${attrs.maxSelect}) {
      selectTarget.isTarget = false;
      }
      else if (!selectTarget.isTarget) {
      selectTarget.isTarget = true;
      }
      }
      """
      }
      }
      };

      ${
      def onDragDropEventCalls = []
      lists.eachWithIndex { listItem, index ->
      onDragDropEventCalls.add "parseListToHiddenInput(YAHOO.util.Dom.get('${listItem.key}'), '${listItem.key}', ${index});\n"
      }
      onDragDropEventCalls.join('')
      }
      };
      YAHOO.util.Event.onDOMReady(GRAILSUI.${jsid}.init, GRAILSUI.${jsid}, true);
      </script>
    • Dav Glass
      Instead of setting isTarget to false, try locking the instance. http://developer.yahoo.com/yui/docs/YAHOO.util.DragDrop.html#method_lock selectTarget.lock();
      Message 2 of 3 , Jun 28, 2009
      • 0 Attachment
        Instead of setting isTarget to false, try locking the instance.
        http://developer.yahoo.com/yui/docs/YAHOO.util.DragDrop.html#method_lock

        selectTarget.lock();
        selectTarget.unlock();


        On Sun, 28 Jun 2009, john j wrote:

        > I am trying to put a size limit on a DragDropTarget by setting its isTarget property to false whenever the size max is reached (implementation uses dragDropEvent). It works as hoped for when trying to add items to the *bottom* of the disabled list. However, when an item is drop-attempted anywhere else in the "disabled" list, the drop goes through w/o rejection. Any hints on how to fix this?
        >
        > Here's the pertinent code (groovy/js):
        >
        > <script>
        > GRAILSUI.${jsid} = {
        > init: function() {
        >
        > ${
        > lists.collect { listItem ->
        > def result = "new YAHOO.util.DDTarget('${listItem.key}');\n"
        > listItem.value.each {
        > result += "var ${it}_dli = new GRAILSUI.DraggableListItem('${it}');\n"
        > result += "${it}_dli.on('dragDropEvent', this.onDragDropEvent);\n"
        > }
        > result
        > }.join('')
        > }
        > this.populateHiddenInput();
        > },
        >
        > onDragDropEvent: function() {
        > var parseListToHiddenInput = function(ul, listName, listIndex) {
        > var items = ul.getElementsByTagName("li");
        > var out = "";
        > for (i=0;i<items.length;i=i+1) {
        > out += items[i].id + " ";
        > }
        > YAHOO.util.Dom.get(listName + '_input').value = out;
        > ${
        > if (attrs.maxSelect) {
        > """
        > if (listIndex == 0) {
        > var selectTarget = this.DDM.ids.default[listName];
        > if (items.length >= ${attrs.maxSelect}) {
        > selectTarget.isTarget = false;
        > }
        > else if (!selectTarget.isTarget) {
        > selectTarget.isTarget = true;
        > }
        > }
        > """
        > }
        > }
        > };
        >
        > ${
        > def onDragDropEventCalls = []
        > lists.eachWithIndex { listItem, index ->
        > onDragDropEventCalls.add "parseListToHiddenInput(YAHOO.util.Dom.get('${listItem.key}'), '${listItem.key}', ${index});\n"
        > }
        > onDragDropEventCalls.join('')
        > }
        > };
        > YAHOO.util.Event.onDOMReady(GRAILSUI.${jsid}.init, GRAILSUI.${jsid}, true);
        > </script>
        >
        >

        --
        Dav Glass
        davglass@...
        blog.davglass.com


        + Windows: n. - The most successful computer virus, ever. +
        + A computer without a Microsoft operating system is like a dog
        without bricks tied to its head +
        + A Microsoft Certified Systems Engineer is to computing what a
        McDonalds Certified Food Specialist is to fine cuisine +
      • mayonesa
        ... Used it but same behavior as isTarget. The file of interest is taglib/MyDragAndDropTagLib.groovy in http://www.nabble.com/file/p24265871/grails-app%2B2.zip
        Message 3 of 3 , Jun 30, 2009
        • 0 Attachment
          Dav Glass wrote:
          >
          > Instead of setting isTarget to false, try locking the instance.
          > http://developer.yahoo.com/yui/docs/YAHOO.util.DragDrop.html#method_lock
          >
          > selectTarget.lock();
          > selectTarget.unlock();
          >

          Used it but same behavior as isTarget. The file of interest is
          taglib/MyDragAndDropTagLib.groovy in
          http://www.nabble.com/file/p24265871/grails-app%2B2.zip grails-app+2.zip
          --
          View this message in context: http://www.nabble.com/DragDropTarget.isTarget-%3D-false-Does-Not-Completely-Work-tp24239075p24265871.html
          Sent from the ydn-javascript mailing list archive at Nabble.com.
        Your message has been successfully submitted and would be delivered to recipients shortly.