我需要for在我的jQuery中有一个循环.
例:
for(i=0;i<counter;i++)
{
$("div"+i+"").click(function(){//some code});
}
Run Code Online (Sandbox Code Playgroud)
我怎么能做到这一点?
此代码由OP发布,对其中一个答案发表评论:
$("#displayPanel div").click(function (){ alert($(this).attr("id")); }
<div id="displayPanel" class="displayPanel">
<div id="heading"> Display Panel </div> <br/>
<div id="save" class="saveClass"></div> <br/>
<div id="field1" class="my">
<label id="labelstr1">Untitled1</label>
<input id="inputstr1" type="text"/>
</div>
<div id="field2" class="my">
<label id="labelstr2">Untitled1</label>
<input id="inputstr2" type="text"/>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
警报显示前两个divs 的id 而不是field1和field2.
该Field1和Field2 divs的动态创建.
我在JQuery中有一个问题.$.ajax()我在我的代码中(Function 1)使用将字段名和序列号发送到ctrller,它通过$_POST['name']和获取数据$_POST['sequenceno']并更新表中的字段名,序列号为no..And生成预览显示面板插入字段..现在我正在尝试再次更改字段名称现在,当我点击生成的显示面板字段时,相应的设置将打开,我将尝试更改字段的名称(Function 2)
无论Function1和Function2相同..In了Function1我送的字段名和顺序没有
在Funciton 2中,我想发送相同的fieldname和(但是另一个值)sequenceno ..
但是在Function1中(sequenceno是计数器值)而在Function2中(sequenceno是单击的div id(显示面板))
我怎样才能为两者使用相同的函数..或者我可以使用单独的函数..
即使我尝试使用2个不同的功能,但没有正确更新
我的代码是
//This is what i insert the field initially
$(".TextFieldSettings #fieldTitle").change(function (){
fieldname=$(".TextFieldSettings #fieldTitle").val();
$.ajax({
type: "POST",
url: "./server",
data: "name="+fieldname+"&sequenceno="+counter,
success: function(msg){
}//success
});//ajax
});//change
//After inserting to get the updated values in JSON format
var htm = $.ajax({
type: "GET",
url: "./viewforms",
async: false
}).responseText;
var myObject = eval('(' + htm + …Run Code Online (Sandbox Code Playgroud) 在我的代码中.我有Div标签,类型="隐藏".我只是不想显示div.只有在需要时我才能通过JQuery来展示它div.
但是我的div仍然没有从视图中隐藏.
编辑现在我使用隐藏DIV
<div style="visibility:hidden">XYZ</div>
Run Code Online (Sandbox Code Playgroud)
如果我需要再次显示它,我该怎么做?
我已经在我的表属性中添加了一个新列,它已经有(id,form_id(外键),类型,标签,大小,序列号,instr)其中instr是我添加的新列.
我的应用程序在CakePHP和MySQL中.
我已经使用以下代码插入表中的属性但是单独的字段instr没有插入.
function saveFieldname($data)//from untitledfieldname
{
$this->data['Attribute']['form_id'] = $this->find( 'all', array(
'fields' => array('Form.id'),
'order' => 'Form.id DESC'
));
$this->data['Attribute']['form_id'] = $this->data['Attribute']['form_id'][0]['Form']['id'];
$this->data['Attribute']['label'] = 'Label';
$this->data['Attribute']['size'] ='50';
$this->data['Attribute']['instr'] ='Fill';
$this->data['Attribute']['type'] = $data['Attribute']['type'];
$this->data['Attribute']['sequence_no'] = $data['Attribute']['sequence_no'];
$this->Attribute->save($this->data);
}
Run Code Online (Sandbox Code Playgroud)
请建议我..
我对 Ruby on Rails 很陌生。运行脚本/控制台时,我得到以下环境..
aruna@aruna-desktop:~/railsprojects/pagesapp$ script/console 加载开发环境 (Rails 2.3.8) sh: irb: 未找到
请大家给点建议..
我在夹具中遇到了一些问题
我有模特优势和善良
advantage.rb
belongs_to :kind
Run Code Online (Sandbox Code Playgroud)
kind.rb
has_many :advantages
Run Code Online (Sandbox Code Playgroud)
advantages.yml
1.
id: 1
title: something
kind: apple
kind_id: 1
Run Code Online (Sandbox Code Playgroud)
2.
id: 2
title: somethjin
kind: orange
kind_id: 2
Run Code Online (Sandbox Code Playgroud)
kinds.yml
apple:
id: 1
name: apple
orange:
id: 2
name: orange
Run Code Online (Sandbox Code Playgroud)
我试图将关联带到这里,因为kind_id带有一些垃圾值
所以我喜欢
kinds.yml
apple:
name: apple
orange:
name: orange
Run Code Online (Sandbox Code Playgroud)
并且在advantage.yml
东西:
title: something
kind: apple
Run Code Online (Sandbox Code Playgroud)
somethjin
title: somethjin
kind: orange
Run Code Online (Sandbox Code Playgroud)
但它没有用
如何解决这个问题
我正在使用rails 3.2并使用coffeescript ..我有一个疑问,在我的应用程序中使用jquery mobile我有一个html像
<a href="#" data-item=12 data-status=true class="follow">
<span class="ui-btn-inner">
<span class="ui-btn-text">
Follow
</span>
</span>
</a>
Run Code Online (Sandbox Code Playgroud)
在我的coffeescript中,我试图点击这个函数来编写函数,我正在尝试发送一个ajax调用.
当我写的时候
$("a.follow").unbind('click').bind 'click', (event, data) ->
event.stopPropagation()
clickedEl = $(event.target)
console.log(clickedEl)
Run Code Online (Sandbox Code Playgroud)
Console.log有时打印带有"ui-btn-text"类的跨度,有时会跨越"ui-btn-inner".
但在我的coffeescript函数中,我需要实际从标记中获取属性.如何处理这个问题
我在我的 rails jquery 移动应用程序中使用 HandleBar.js。
我有一个 json 返回值 data= "hi\n\n\n\n\nb\n\n\n\nhow r u"
当在 .hbs 文件中使用时,它{{data}}显示我作为hi how r u而不是实际插入的新行
请建议我。
预标签帮助我
我在我的Rails 3.2 jquery移动应用程序中使用Handlebar.
我试图在Coffeescript方法中编写一个switch case语句
Handlebars.registerHelper 'status', (blog) ->
switch(parseInt(blog.status))
when [0..20]
status = "active"
when [20..40]
status = "Moderately Active"
when [40..60]
status = "Very Active"
when [60..100]
status = "Hyper Active"
return status
Run Code Online (Sandbox Code Playgroud)
我没有得到任何结果.如何在何时使用范围.请建议
我正在使用Joomla 1.5.我有一个页面,其中为标题添加了cSS<strong></strong>
我骂了它,看起来像
element.style {
color:#666666;
}
Run Code Online (Sandbox Code Playgroud)
我不知道它来自哪里..
但我有一个css申请与其他颜色相同的标签.但它消失了.如何全局删除element.style ..
coffeescript ×2
jquery ×2
ajax ×1
cakephp ×1
css ×1
element ×1
fixtures ×1
html ×1
javascript ×1
mysql ×1
visibility ×1