我只是玩jqplot几个小时,但我找不到如何以更具体的jquery方式指定目标.例如,如果我有HTML代码:
<div id="chart"></div>
Run Code Online (Sandbox Code Playgroud)
我可以使用创建图表
$.jqplot("chart", [], {});
Run Code Online (Sandbox Code Playgroud)
它将在id:chart的元素上创建一个图表.
我想要的是使用这样的东西:
$("#chart").jqplot([], {});
Run Code Online (Sandbox Code Playgroud)
要么
$(".multiple_charts").jqplot([], {});
Run Code Online (Sandbox Code Playgroud)
要么
var myChart=$("<div></div>");
myChart.jqplot([], {});
Run Code Online (Sandbox Code Playgroud)
我看到这个问题已在2009年提出:https://bitbucket.org/cleonello/jqplot/issue/114/jqplot-target-should-accept-any-element
我正在寻找什么解决方案?谢谢
简单的任务.我正在使用jetty的websockets服务器实现,我必须获取客户端IP地址,但我不知道如何.
只是想知道如何从内存的角度来管理这个问题.
假设我有这个HTML页面.
<div id="container">
<div id="someID"></div>
<div>
Run Code Online (Sandbox Code Playgroud)
和以下jQuery代码:
$("#someID").click(function(){
//do something
});
Run Code Online (Sandbox Code Playgroud)
现在我的脚本中的某个地方我需要清空(清除)所有内容#container
:
$("#container").empty();
Run Code Online (Sandbox Code Playgroud)
这会自动删除/取消绑定点击事件,还是我自己必须这样做?
这是浏览器特有的吗?
我不确定这是否是实现此目的的最佳方法。如果您有其他意见请分享。
我必须实现一个多收件箱系统,用户可以将多封电子邮件按不同的收件箱分组。
例如:http://localhost/inbox/personal/
将在收件箱中显示电子邮件列表personal
,http://localhost/inbox/business/3
将在收件箱中显示电子邮件列表business
,并突出显示带有 id 的电子邮件:3
路线如下:
const routes: Routes = [
{
path: '',
pathMatch: 'full',
redirectTo: 'personal' // redirect to personal inbox
},
{
path: ':inbox',
component: InboxContentComponent, // list of emails in :inbox
children: [
{
path: '',
component: InboxNoSelectedEmailComponent, // no email selected
},
{
path: ':id',
component: InboxSelectedEmailComponent, // show selected email content
}
]
}
];
Run Code Online (Sandbox Code Playgroud)
我的问题是InboxContentComponent
. 我需要检测收件箱何时更改以及是否选择了电子邮件
constructor(private route: ActivatedRoute) {
}
ngOnInit() …
Run Code Online (Sandbox Code Playgroud) 我希望能够根据某些条件更改javascript文件中的变量和函数名称,然后输出修改后的javascript.这类似于javascript minifier的功能.这是一个例子:我有这个javascript代码
var something=5;
something++;
function doSomething(n){
alert(n);
}
doSomething(something):
Run Code Online (Sandbox Code Playgroud)
现在我想更换something
,并doSomething
用somethingElse
和doSomethingElse
,并返回下面的JavaScript代码:
var somethingElse=5;
somethingElse++;
function doSomethingElse(n){
alert(n);
}
doSomethingElse(somethingElse):
Run Code Online (Sandbox Code Playgroud)
我认为这可以在rhino或google closure编译(基于rhino)中完成,但不知道如何.我也对其他建议持开放态度.
谢谢
我正在尝试构建一个发出自定义事件的组件.我不确定为什么没有触发事件.如果我查看浏览器开发人员工具,我可以看到事件附加到元素.
我甚至尝试创建角度文档提供的小示例:https://angular.io/docs/ts/latest/api/core/Output-var.html但没有运气.
这是小代码:
import {Component} from "angular2/core";
import {Directive} from "angular2/core";
import {Output} from "angular2/core";
import {EventEmitter} from "angular2/core";
import {bootstrap} from "angular2/platform/browser";
@Directive({
selector: 'interval-dir',
})
class IntervalDir {
@Output() everySecond = new EventEmitter();
@Output('everyFiveSeconds') five5Secs = new EventEmitter();
constructor() {
setInterval(() => this.everySecond.emit("event"), 1000);
setInterval(() => this.five5Secs.emit("event"), 5000);
}
}
@Component({
selector: 'app',
template: `
<interval-dir (every-second)="everySecond()" (every-five-seconds)="everyFiveSeconds()">
</interval-dir>
`,
directives: [IntervalDir]
})
class App {
everySecond() { console.log('second'); }
everyFiveSeconds() { console.log('five seconds'); …
Run Code Online (Sandbox Code Playgroud) 我有这个Java代码:
public interface User{
public void in(Message message);
}
public interface Message{
//....
}
public interface WebsiteMessage extends Message{
//....
}
public class WesiteUser implements User{
@Override
//I'm not allowed to do this
public void in(WebsiteMessage message){}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法in
用WebsiteMessage参数实现该方法?目前我正在做这样的事情:
@Override
public void in(Message message){
WebsiteMessage msg= (WebsiteMessage) message;
//..
}
Run Code Online (Sandbox Code Playgroud)