首页 \ 问答 \ 如何在jqueryui droppable中使用danymic accept值?(how to use danymic accept value in jqueryui droppable?)

如何在jqueryui droppable中使用danymic accept值?(how to use danymic accept value in jqueryui droppable?)

我正在使用Jquery-ui。 我在一个页面中有不同的可拖放的ul(s),也有不同的可拖动的li(s)。 我想要的是:1. ul的标题不同,比如“FUNCTION”,“BUG”等等。2. li由于他们的类别而不同,比如“.FUNCTOIN”,“.BUG”,等等。3.带有“FUNCTION”标题的ul只能通过类“.FUNCTION”等接受li。4.只能在视图中创建ul(s)的标题时根据某些存储在数据库中的值。

但是后来我发现了一些问题,下面是不同的饱和度:

如果我使用常数值,它运作良好,如:

        $("ul.droppable").droppable({
            accept: ".FUNCTION",

而以下所有方式都失败了:

        $("ul.droppable").droppable({
            accept: "." + $(this).attr("title"), 

        $("ul.droppable").droppable({
            accept: '.' + $(this).attr("title"), 

        $("ul.droppable").droppable({
            accept: "\." + $(this).attr("title"), 

        $("ul.droppable").droppable({
            accept: '\.' + $(this).attr("title"), 

所以我把“。” 在标题和尝试以下,但他们都失败了:

        $("ul.droppable").droppable({
            accept: $(this).attr("title"), 

顺便说一句,当我的意思是“失败”,没有错误,弹出等。可droppable只是没有工作(不活跃,没有徘徊,不能放弃。)。

我发现很多演示或Q / A这个“接受”,但他们都在使用可以在运行时定义的东西。 所以“接受”只能使用恒定的价值,或者我使用它的方式是错误的? 感谢您的回答或建议或意见,这可能会有所帮助。


根据Xnake的回答,这样做的结论是:

在旧的可投入代码之前,添加前三行:

        $("ul.droppable.accept").droppable({
            accept: function (e) { if (e.hasClass($(this).attr('accept'))) return true; }
        });
        $("ul.droppable").droppable({
            activeClass: "ui-state-default",
            ... //this is the old code.

这意味着如果我们给可接受的ul赋予一个“接受”类,它将只接受具有某个类的对象; 否则,它可以接受任何可拖动的。

然后在视图中:

<ul class = "stories-of-category droppable accept" accept = "@map.Type" >
...
</ul>

如果有任何与@ map.Type具有相同名称的对象,则可以在此删除它。 例如:

<ul title = ".."> //this is another ul.
    <li class = "@map.Type">
        @map.Title
    </li>
    ...
</ul>

I'm using the Jquery-ui. I have different droppable ul(s) in one page, and different draggable li(s) too. What I wanted was that: 1. ul differ from each other by their title, like "FUNCTION", "BUG", etc. 2. li differ from each other by their class, like ".FUNCTOIN", ".BUG", etc. 3. ul with title of "FUNCTION" can only accept li with class ".FUNCTION", etc. 4. the titles of the ul(s) can only be known while they are being created in the View, according to some values stored in the db.

but then i encuntered some problems, here are the different satuations:

if i use constant value, it works well, like:

        $("ul.droppable").droppable({
            accept: ".FUNCTION",

while all the following ways failed:

        $("ul.droppable").droppable({
            accept: "." + $(this).attr("title"), 

        $("ul.droppable").droppable({
            accept: '.' + $(this).attr("title"), 

        $("ul.droppable").droppable({
            accept: "\." + $(this).attr("title"), 

        $("ul.droppable").droppable({
            accept: '\.' + $(this).attr("title"), 

so i put the "." in the title and tried the following, but all of them failed:

        $("ul.droppable").droppable({
            accept: $(this).attr("title"), 

btw when i mean "failed", there is no error, pop up, etc. The droppable just didn't work (not active, not hovered, can not drop.).

I found lot's of demoes or Q/A of this "accept", but all of them are using something that can be defined before runtime. So the "accept" can use only constant value, or the way i'm using it was wrong? Thanks for answer or recommandations or comments that may help.


According to the answer from Xnake, the way to do it was conclude to:

before the old code of droppable, add the first 3 lines:

        $("ul.droppable.accept").droppable({
            accept: function (e) { if (e.hasClass($(this).attr('accept'))) return true; }
        });
        $("ul.droppable").droppable({
            activeClass: "ui-state-default",
            ... //this is the old code.

That means if we give a "accept" class to the droppable ul, it will accept only object with some class; otherwise, it can accept any draggable.

Then in the view:

<ul class = "stories-of-category droppable accept" accept = "@map.Type" >
...
</ul>

if any object with class of the same name with @map.Type, it can be dropped here. For example:

<ul title = ".."> //this is another ul.
    <li class = "@map.Type">
        @map.Title
    </li>
    ...
</ul>

原文:https://stackoverflow.com/questions/6501812
更新时间:2023-11-10 12:11

最满意答案

我无法找到设置Edge浏览器主页的工作方式,所以作为另一种选择,我使用WebView创建了一个应用程序,并允许它在AssignedAccess.xml文件中运行。


I could not find a working way of setting the home page for Edge browser, so as an alternative I've created an app with a WebView and allowed it to be run in AssignedAccess.xml file.

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。