问题列表 - 第42216页

在jQuery插件中停止setInterval

我正在尝试编写一个我正在编写的插件,但是我很难找到一个我无法找到解决方案的非常微不足道的问题.我已经找到了几乎每个论坛和相关的问题讨论.这里的任何方式都是我想要发生的,我的插件有一个计时器,我希望用户能够处理它的终止.

(function ($) {
...
var defaults = {
 callback : function(){},
 crossfadeTime : 1000,
 easing : 'linear',
 running : 'true', // Here is where I would like the user to send a parameter 
                   // to invoke a different result. i.e. 'false' => clearing 
                   // the timer. Such as...

var timer = setInterval(function(){
  // Do Something;
},3000);

if(defaults.running == 'false'){
  clearInterval(timer);
}
Run Code Online (Sandbox Code Playgroud)

jquery setinterval

2
推荐指数
1
解决办法
3531
查看次数

Netbeans maven添加模块

在Netbeans中,如何使用IDE将模块添加到多模块maven项目中.在Eclipse中,我可以右键单击项目>添加>新建>其他> maven模块.netbeans是否具有类似的功能.

netbeans maven

6
推荐指数
1
解决办法
4417
查看次数

Windows.Forms.Timer或System.Threading.Timer

我有一个运行许多线程的应用程序.每个线程都应该有一个计时器来检查该线程范围内的某些内容.我的问题是:我应该使用哪个计时器,它们之间有什么区别?

.net c# timer

46
推荐指数
1
解决办法
1万
查看次数

使用swank/slime了解Clojure中的输出

当我在emacs中从Swank repl运行Clojure代码时,主线程将使用printf将消息打印到repl.但是如果我运行代理或显式创建其他也打印的线程,有时输出不会显示,有时它会显示在我运行Swank的控制台窗口中.我很想知道为什么.

编辑:感谢丹尼尔的回答下面我现在知道了其他线程不必绑定到REPL的输出.此代码有效,因为您从运行的位置传出.但是我的新问题是这个代码现在阻塞每个线程,所以不是并行运行,而是每次运行一个线程,所以我需要一个更多线程感知的输出方法.

(defn sleeper-thread [out id t]
  "Sleep for time T ms"
  (binding [*out* out]
    (printf "%d sleeping for time %d\n" id t)
    (Thread/sleep t)
    (printf "%d slept\n" id)))

(defn test-threads [n out]
  (dotimes [x n]
    (.start (Thread. (#(sleeper-thread %1 %2 %3) out x (+ 2000 (rand-int 5000)))))))
Run Code Online (Sandbox Code Playgroud)

printf multithreading clojure slime

6
推荐指数
1
解决办法
556
查看次数

jQuery multiselect下拉列表,包含所选项目的关闭按钮

基本上我想要这样的东西.我有哪些现成的选择?这种小部件有没有合适的短名称?

http://confluence.atlassian.com/download/attachments/225116342/components.PNG?version=1&modificationDate=1286851639207

javascript jquery multi-select

6
推荐指数
0
解决办法
3441
查看次数

返回const'the'指针

如果this是一个指向类对象的const指针,你怎么能从非const返回类型返回一个const指针?

Class T
{
 public:
   T* func(){return this;}
};
Run Code Online (Sandbox Code Playgroud)

c++

8
推荐指数
1
解决办法
7596
查看次数

定义整数(int); 什么是默认值?

int i;
int data[5] = {0};
data[0] = i;
Run Code Online (Sandbox Code Playgroud)

数据[0]的价值是多少?

另外,这条线的含义是什么?

if (!data[0]) { ... }
Run Code Online (Sandbox Code Playgroud)

c int

12
推荐指数
3
解决办法
4万
查看次数

django.db.utils.DatabaseError

我正在设置一个django模型来存储区域,比如美国,德国等.我使该区域的名称独一无二.我有一个脚本从列表中填充数据库,如果有一个重复的区域名称IntegrityError按预期抛出,但然后发生另一个错误,我无法从错误消息中说出原因.有任何想法吗?谢谢!

django.db.utils.DatabaseError: current transaction is aborted, commands ignored until end of transaction block
Run Code Online (Sandbox Code Playgroud)

模型:

class Region(models.Model):
    name = models.CharField(max_length=512, unique=True)

    def __unicode__(self):
        return self.name
Run Code Online (Sandbox Code Playgroud)

填充代码:

    try:
        Region(name=server['locale']).save()
        print 'Added region: %(locale)s' % server
    except IntegrityError:
        pass
Run Code Online (Sandbox Code Playgroud)

我已经确认IntegrityError正在发生,但后来我得到了这个我不希望的错误:

  File "/home/daedalus/webapps/wowstatus/lib/python2.6/django/db/models/base.py", line 456, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File "/home/daedalus/webapps/wowstatus/lib/python2.6/django/db/models/base.py", line 549, in save_base
    result = manager._insert(values, return_id=update_pk, using=using)
  File "/home/daedalus/webapps/wowstatus/lib/python2.6/django/db/models/manager.py", line 195, in _insert
    return insert_query(self.model, values, **kwargs)
  File "/home/daedalus/webapps/wowstatus/lib/python2.6/django/db/models/query.py", line 1518, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/home/daedalus/webapps/wowstatus/lib/python2.6/django/db/models/sql/compiler.py", line 788, in …
Run Code Online (Sandbox Code Playgroud)

python django

5
推荐指数
1
解决办法
8198
查看次数

Ajax.BeginForm让我发疯

ASP.NET MVC3

我有一个局部视图,最初在div中呈现.以下是部分代码:

@model Venue.Models.Validation.CustomerRequestModel

<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<script type="text/javascript" src="/Scripts/MicrosoftAjax.js"></script>
<script type="text/javascript" src="/Scripts/MicrosoftMvcAjax.js"></script>
<script type="text/javascript" src="/Scripts/MicrosoftMvcValidation.js"></script>

@{ Html.RenderPartial("Message"); }
@Html.ValidationSummary()

@using (Ajax.BeginForm(
            "Customer",
            "Service",
            null,
            new AjaxOptions()
            {
                HttpMethod = "post",
                InsertionMode = InsertionMode.Replace,
                LoadingElementDuration = 100,
                LoadingElementId = "loading-customer",
                OnBegin = "hideSubmitButton",
                OnSuccess = "hideForm",
                OnComplete = "showSubmitButton",
                OnFailure = "showErrorMessage",
                UpdateTargetId = "formclientes",
            },
            new
            {
                id = "customer-form"
            }))
{
    // Fields are all type="text" although some are numbers.
    <input …
Run Code Online (Sandbox Code Playgroud)

asp.net-ajax ajax.net asp.net-mvc-3

2
推荐指数
1
解决办法
1万
查看次数

使用GCC在Ubuntu上编译Objective-C

好的,我有这个程序在这里:

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    NSLog (@"Hello world!");
    [pool drain];
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

问题是当我使用命令"gcc -framework Foundation prog1.m -o prog1"编译它时

我得到这个:"gcc:错误试图执行'cclobj':execvp:没有这样的文件或目录"

我需要安装任何包吗?"

ubuntu gcc objective-c gnustep

3
推荐指数
1
解决办法
5202
查看次数