小编kyl*_*rns的帖子

jQuery UI Datepicker - 为什么第二个datepicker会在onfocus上消失?

我有两个input作为jQuery UI datepickers的元素.在第一个datepicker元素上进行选择后,它应该自动关注第二个datepicker元素并显示日历,以便您轻松快速地做出选择.

无论出于何种原因,第二个日期选择器/日历出现片刻然后消失.我不确定它为什么会消失; 任何人都可以向我解释为什么它正在消失并且可能的解决方案?

目前使用以下库:jQuery 1.8.3,jQuery UI 1.9.2

这是我目前使用的代码:

<ul class="fields">
    <li><label>Date picker #1</label>
        <input type="text" class="date-picker-1" />
    </li>
    <li><label> Date picker #2</label>
        <input type="text" class="date-picker-2" />
    </li>
</ul>

$('input.date-picker-1').datepicker({
    constrainInput: true,
    hideIfNoPrevNext: true,
    onSelect: function () {
        $(this).closest('.fields')
           .find('.date-picker-2').datepicker('show');
    }
});

$('input.date-picker-2').datepicker({
    onFocus: 'show'
});
Run Code Online (Sandbox Code Playgroud)

这是一个小提琴:http://jsfiddle.net/B78JJ/

如果有任何其他信息有用,请随时提出,我将很乐意提供帮助.

javascript jquery jquery-ui jquery-ui-datepicker

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

在Angular 2中获取父路由参数(路由器v3.0.0-alpha.6)

展望设置使用的一个网站谷歌的推荐的多区域和多语言网站的做法,利用子目录与gTLD的(例如特别的模型.www.stackoverflow.com/en/questions/ask,www.stackoverflow.com/fr/questions/ask等).

根据顶级子目录,我想设置默认语言并获取相应的JSON数据.进一步解释,当用户直接导航到www.mywebsite.com/en/home时,默认语言将被设置为en,我的内容服务将获取该en.json文件.

在上面的示例中,我的路由将配置如下:

export const routes: RouterConfig = [
  { path: ':country',          component: Home },
  { path: ':country/home',     component: Home },
  { path: ':country/about',    component: About },
  { path: ':country/contact',  component: Contact }
];
Run Code Online (Sandbox Code Playgroud)

我试图找出如何抓住:country路线参数(如果网址是www.mywebsite.com/en/about/我试图让:country路由参数值en)的时候Home,AboutContact组件.这是我尝试过的几件事:

export class Home implements OnInit {
    constructor(
        private route: ActivatedRoute
    ) {}

    private sub: any;

    ngOnInit(){
       this.sub = this.route.params.subscribe(params => {
         let country …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-routing angular2-template

4
推荐指数
1
解决办法
3449
查看次数

使用PHP格式化URL - http://www.google.com到www.google.com/; 还有str_replace()的问题

我在执行以下操作时遇到了一些麻烦..

http://www.google.com - > www.google.com/
https://google.com - > www.google.com/
google.com - > www.google.com/

我试图删除https:// or http://,确保将www.其添加到URL的开头,然后如果URL不存在则向URL添加尾部斜杠.

感觉就像我已经把这个中的大部分弄清楚但是我无法开始str_replace()工作我是怎么想的.

根据我的理解,这是如何使用str_replace:

$string = 'Hello friends';
str_replace('friends', 'enemies', $string);
echo $string;
// outputs 'Hello enemies' on the page
Run Code Online (Sandbox Code Playgroud)

这是我到目前为止:

$url = 'http://www.google.com';

echo reformat_url($url);

function reformat_url($url) {
    if ( substr( $url, 0, 7 ) == 'http://' || substr( $url, 0, 8 ) == 'https://' ) { // if http:// or https:// is at the beginning of …
Run Code Online (Sandbox Code Playgroud)

php url substr str-replace

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