我正在使用一个查看器,它使用JList显示文档页面的缩略图.用户可以通过在JList中选择它或通过其他机制打开页面,例如在文本框中输入数字.
当使用后者替代时,我希望JList也选择页面.我使用setSelectedIndex()执行此操作,但这会触发一个事件,这会导致再次加载页面,就好像用户单击并选择了JList中的页面一样,这导致了一些问题.
我怎么看,索引应该以某种方式设置(可能在模型中),这样只有JList的UI更新,而不会触发索引已更改的事件.
这可能吗?或者有更好的方法来解决我的问题吗?
我想编写一个函数来获取指定用户的所有推文,但它最近只返回20个.
我想出了类似的东西:
function getTweets($user) {
$page = file_get_contents("http://twitter.com/{$user}");
$from = strpos($page, "<ol id='timeline' class='statuses'>");
$to = strpos($page, "</ol>");
$length = $to - $from;
$page =substr($page, $from, $length);
echo $page;
}
getTweets('user_name');
Run Code Online (Sandbox Code Playgroud)
有没有办法绕过那个?
我有一个多选列表框,在提交表单之前我想检查用户是否通过jquery选择任何选项
我想在某个diapason中生成随机数,我必须确定,每个新数字都不是前者的副本.一种解决方案是将以前生成的数字存储在容器中,并且每个新数字都检查容器.如果容器中有这样的数字,那么我们生成agin,否则我们使用并将其添加到容器中.但是对于每个新的数字,这个操作变得越来越慢.有没有更好的方法,或任何可以更快地工作并确保代的唯一性的兰特函数?
编辑:是的,有一个限制(例如从0到1.000.000.000).但我想生成100.000个唯一数字!(如果解决方案是使用Qt功能,将会很棒.)
我在ASP.NET网站上有付款的表单,当用户点击asp:Button时,他提交了几次.我想在不损害当前ASP.NET站点的情况下禁用此功能(我的意思是没有花哨的jQuery,除非它非常基本且不会干扰ASP.NET内置验证)
谢谢!!!
我尝试在我的HTML模板上保持一个有点一致的命名方案.即index.html for main,delete.html for delete page等等.但是app_directories加载器总是似乎从按字母顺序排列的应用程序加载模板.
有没有办法总是先在调用应用程序的templates目录中检查匹配?
我的相关设置settings.py:
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
TEMPLATE_LOADERS = (
'django.template.loaders.app_directories.load_template_source',
'django.template.loaders.filesystem.load_template_source',
)
TEMPLATE_DIRS = (
os.path.join(PROJECT_PATH, 'templates'),
)
Run Code Online (Sandbox Code Playgroud)
我试过改变顺序TEMPLATE_LOADERS,没有成功.
按照Ashok的要求编辑:
每个应用程序的目录结构:
templates/
index.html
add.html
delete.html
create.html
models.py
test.py
admin.py
views.py
Run Code Online (Sandbox Code Playgroud)
在每个应用程序的views.py中:
def index(request):
# code...
return render_to_response('index.html', locals())
def add(request):
# code...
return render_to_response('add.html', locals())
def delete(request):
# code...
return render_to_response('delete.html', locals())
def update(request):
# code...
return render_to_response('update.html', locals())
Run Code Online (Sandbox Code Playgroud) 我尝试在Ubuntu 10.04上使用kdevelop 3.5.4编译应用程序,但它失败并出现以下错误:
checking whether make sets $(MAKE)... yes
checking for g++... g++
checking whether the C++ compiler works... no
configure: error: in `/home/nts/wktools4':
configure: error: C++ compiler cannot create executables
See `config.log' for more details.
*** Exited with status: 77 ***
Run Code Online (Sandbox Code Playgroud)
的config.log:
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.65. Invocation command line was
$ /home/nts/wktools4/configure …Run Code Online (Sandbox Code Playgroud) 我意识到在gvim中Control+S作为:update命令.我总是保存使用Ctrl+S,所以我认为这:update是另一种说法"刷新变化".是:update基本相同的写:w?如果我更换:update,我会遇到问题:w!吗?
编辑:我想更改:update为:w!因为我有一个文件说"准备就绪,请添加" !.我认为这是唯一的解决方案
我想在客户端获取Tomcat的JSESSIONID.那可能吗?如果有,怎么样?
谢谢
我正在修复IE7的错误,这个让我难过.此页面中的内容大于其包含的div.IE7正确显示垂直滚动条,但内容位于垂直滚动条的顶部,当用户单击滚动按钮时,内容不会移动.我无法想象造成这种情况的原因.有任何想法吗?
编辑:我附上了问题的截图: 替代文字http://img31.imageshack.us/img31/605/picture5kw.png