我试图有一个按钮,loading在发出一系列 ajax 请求之前,onclick 会将一个类(将光标设置为“等待”)应用于主体。
代码是:
$('#addSelected').click(function(){
$('body').addClass('loading');
var products = $(':checkbox[id^=add_]:checked');
products.each(function(){
var prodID = $(this).attr('id').replace('add_', '');
var qty = $('#qty_' + prodID).val();
if($('#prep_' + prodID).val())
{
prodID += ':' + $('#prep_' + prodID).val();
}
// Have to use .ajax rather than .get so we can use async:false, otherwise
// product adds happen in parallel, causing data to be lost.
$.ajax({
url: '<?=base_url()?>basket/update/' + prodID + '/' + qty,
async: false,
beforeSend: function(){
$('body').addClass('loading');
}
});
});
}); …Run Code Online (Sandbox Code Playgroud) 我一直在玩Codeigniter创建一个电子商务网站,我正在努力做到以下几点:
将类别名称作为第一个参数,例如
/tshirts/shoes以下每个都是过滤器(在类别上)或产品(在SEO的URL中有类别)
/tshirts/filter/price/0-20/tshirts/pink-with-blue-spots我目前在路由中做的是:
$route['tshirts'] = 'category/index';
$route['tshirts/(filter|sort)'] = 'category/index';
$route['tshirts/(filter|sort)/:any'] = 'category/index/filter';
$route['tshirts/:any'] = 'product/index';
Run Code Online (Sandbox Code Playgroud)
我想将前两行合并为一行,因为它们正在访问相同的控制器和方法.
第二行是在某人之后移除部件/filter/,并且可能与另一条路线合并.
最后一个路由表示第二个参数是产品名称,因此必须传递给产品控制器.
我一直在玩http://gskinner.com/RegExr/并提出以下内容,这可能很接近,我认为我只需要将括号中的部分作为选项(它正在拾取正确的路线,除了一个没有任何第二个参数),但我不知道如何.
category/?(filter|sort|page)
Run Code Online (Sandbox Code Playgroud)
谢谢!
我在使用SmoothDivScroll插件与Google Chrome配合使用时遇到问题.它在FF和IE7及以上版本中工作正常.我试过玩CSS,但没有结果.
插件就是这个http://www.maaki.com/thomas/SmoothDivScroll/
我在我的服务器上放了一个示例页面
任何人的想法?
谢谢
使用Angular 4.0.3
我正在创建一个组件my-component,它有一个输入value,并ng-template作为内容传递.示例用法是:
<my-component [value]="value">
<ng-template let-value>
<p><strong>Value rendered in user supplied template: {{value}}</strong></p>
</ng-template>
</my-component>
Run Code Online (Sandbox Code Playgroud)
这是my-component确定用户是否在移动设备上的工作.如果是,我们想渲染一个my-native-component.否则,它将呈现一个my-custom-component.
我my-component到目前为止的代码是:
@Component({
selector: 'my-component',
template: `
<my-custom-component *ngIf="useCustom" [value]="value">
<ng-template [ngTemplateOutlet]="templateVariable"></ng-template>
</my-custom-component>
<my-native-component *ngIf="!useCustom" [value]="value">
<ng-template [ngTemplateOutlet]="templateVariable"></ng-template>
</my-native-component>
`
})
class MyComponent {
@ContentChild(TemplateRef)
private templateVariable: TemplateRef;
@Input()
private value: string;
@Input()
private useCustom: bool = false;
}
Run Code Online (Sandbox Code Playgroud)
为了使示例简单,没有检查用户是否在移动设备上.而是useCustom添加了一个输入.
作为内容传递的模板被引用为templateVariable,和通过新的模板传递ng-template和ngTemplateOutlet.
在这个例子中, …
目前我有两张桌子,products而且options.
产品包含
选项包含
样本数据可能是:
Products
id:1
标题:'test'
描述:'我的描述'
Options
id:1
product_id:1
sku:1001
title:'red'
id:2
product_id:1
sku:1002
title:'blue'
我需要显示每个项目,每个不同的选项.此刻,我选择行products并迭代它们,并为每个行选择适当的行options.然后我创建一个数组,类似于:
[product_title] = 'test';
[description] = 'my description';
[options][] = 1, 1001, 'red';
[options][] = 2, 1002, 'blue';
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法只使用sql(我使用codeigniter,并且理想情况下喜欢使用Active Record类)?