好的,我们开始:
<div class="streamItem clearfix">
<input type="button" />
<div class="clientStrip">
<img src="" alt="${Sender}" />
</div>
<div class="clientView">
<a href="#" class="clientName">${Sender}</a>
<p>${Value}</p>
<p>${DateTime}</p>
<div class="itemGadgets">
<ul>
<li class="toggleInput">Value</li>
<li></li>
</ul>
</div>
<div class="inputContainer">
<input type="text" value="" />
</div>
</div>
</div>
<div class="spacer" />
$('.toggleInput').live('click', function () {
$(this).parent().parent()
.find('.inputContainer').toggle();
$(this).parent().parent().find('.inputContainer')
.find('input[type=text]').focus();
});
$('.toggleInput').live('click', function () {
$(this).closest(".clientView").find(".inputContainer").toggle()
$(this).closest(".clientView").find(".inputContainer")
.find('input[type=text]').focus();
});
jQuery 问题:
我有属于每个 .streamItem 的评论.我以前的解决方案是使用 ListView控制如下:
<ItemTemplate>
<asp:Panel ID="StreamItem" CssClass="StreamItem" runat="server">
...
<!-- Insert another nested ListView control here to load the comments for the parent stream. -->
如您所见,这不是解决方案,因为我开始使用 jQuery 模板并且我正在使用以下 jQuery $.ajax 获取数据方法:
$.ajax({
type: 'POST',
url: 'Services.asmx/GetStream',
data: "{}",
contentType: 'application/json',
success: function (Stream) {
$.get('Templates/Stream.html', function (template) {
$.tmpl(template, Stream.d).appendTo("#Stream");
});
}
});
如何在不使用旧的 ListView 的情况下解决这个问题?解决方案,而是通过使用 jQuery 模板在我获取特定流的数据时加载评论? 我使用的是一个简单的 WebMethod返回我的数据如下:
[WebMethod]
public List<Stream> GetStream()
{
List<Stream> Streams = Stream.GetRange(X, X, HttpContext.Current.User.Identity.Name);
return Streams;
}
我正在寻找一种方法来处理 .toggleInput点击事件。我需要检查 .Comments ((作为评论容器 <div> )的一个主容器)有 child (或多个 .commentItem )。如果是这样,那么我需要证明 .inputContainer并隐藏所有其他 .inputContainer divs与.评论size() == 0如果它们可见。
请看下图:
#globalContainer div
{
float : right;
position : relative;
display : inline-block; /* <-- Thank you Firebug. */
}
div.streamItem div.clientView
{
float : left;
width : 542px;
}
div.streamItem div.clientView p
{
margin : 5px 0 0 0;
font-size : 10pt;
}
div.streamItem div.clientView
div.inputContainer
{
display : none; /* Doesn't hide .inputContainer */
padding : 2px;
background-color : #f1f1f1;
}
CSS 问题:
页面加载时,display: none;没有影响。
就是这样!如果您正在阅读本文,我要感谢您的时间和想法! :)
最佳答案
你正在尝试访问错误位置的元素
在 js 中:
$('.toggleInput').live('click', function () {
$(this).parent().parent()
....
它是否没有 .inputContainer 子元素 - 没有什么可切换的
(.closest 也不起作用,因为 .inputContainer 不是 .toggleInput 的父级,而是它的父级兄弟)
jQuery 选择器将是 $(this).closest('.itemGadgets').next();
在您的点击处理程序中
var $currentInputContainer = $(this).closest(".clientView").find(".inputContainer");
....
$('.inputContainer').each(function(){
var $this = $(this);
$this.toggle( $('.commentItem', $this).length > 0 );
});
//but it is better always to show the inputContainer which link was clicked
$('.inputContainer').not($currentInputContainer).each(function(){./*toggle empty|not empty containers */..});
$currentInputContainer.show();
关于c# - CSS + jQuery - 无法执行 .toggle() 并重复 jQueryTemplate Item [我必须警告你这有点让人不知所措],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8155570/
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我在MiniTest::Spec和Capybara中使用以下规范:find_field('Email').must_have_css('[autofocus]')检查名为“电子邮件”的字段是否具有autofocus属性。doc说如下:has_css?(path,options={})ChecksifagivenCSSselectorisonthepageorcurrentnode.据我了解,字段“Email”是一个节点,因此调用must_have_css绝对有效!我做错了什么? 最佳答案 通过JonasNicklas得到了答案:No
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
我在pry中定义了一个函数:to_s,但我无法调用它。这个方法去哪里了,怎么调用?pry(main)>defto_spry(main)*'hello'pry(main)*endpry(main)>to_s=>"main"我的ruby版本是2.1.2看了一些答案和搜索后,我认为我得到了正确的答案:这个方法用在什么地方?在irb或pry中定义方法时,会转到Object.instance_methods[1]pry(main)>defto_s[1]pry(main)*'hello'[1]pry(main)*end=>:to_s[2]pry(main)>defhello[2]pry(main)
我使用的是Firefox版本36.0.1和Selenium-Webdrivergem版本2.45.0。我能够创建Firefox实例,但无法使用脚本继续进行进一步的操作无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055)错误。有人能帮帮我吗? 最佳答案 我遇到了同样的问题。降级到firefoxv33后一切正常。您可以找到旧版本here 关于ruby-无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055),我们在StackOverflow上找到一个类
当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub