由于ember不喜欢的直接dom操作,弹出库是不是与Ember一起工作的?有没有像这样的其他库可以很好地与ember一起使用?
即使通过下面发布的工作示例,我也无法在本地工作.我终于使用了Pine Notify,它可以直接使用.
使用capistrano 3添加环境变量的最佳方法是什么?
我试过了两个
set :default_env, {
'MAILCHIMP' => 'verylongstring'
}
Run Code Online (Sandbox Code Playgroud)
和
set :default_environment, {
'MAILCHIMP' => 'verylongstring',
}
Run Code Online (Sandbox Code Playgroud)
但似乎没有人做任何有用的事情.
我在传单地图上同时打开多个弹出窗口,它们可以重叠。如果点击,我想在前面显示一个弹出窗口。虽然我map.on('click', function(e) {do something;});可以轻松地点击地图,但我似乎无法用弹出窗口做同样的事情。
我怎样才能在 L.Popup 上捕捉点击事件?
我正在使用谷歌地图切换到leaflet.js.我在谷歌地图中做的一件事似乎无法在leaflet.js中找到,它是计算从地图中心(即搜索位置)到地图两侧的半径.您可以放大和缩小人们正在查看的区域可能会发生显着变化.下面的代码显示了我用谷歌地图做的几行.有人能指出我关于leaflet.js的正确方向吗?
// viewport stores the recommended viewport for the returned result.
// (LatLngBounds)
viewportLatLngBounds = zip.get("location").geometry.viewport;
this.map.fitBounds(viewportLatLngBounds);
this.collection.latitude = viewportLatLngBounds.getCenter().lat();
this.collection.longitude = viewportLatLngBounds.getCenter().lng();
// calculate radius
// get distance..
// from (lat of NE corner), (lng of center)
// to (lat of center), (lng of center)
topCenterLatLng = new google.maps.LatLng(viewportLatLngBounds.getNorthEast().lat(), viewportLatLngBounds.getCenter().lng());
metersRadius = google.maps.geometry.spherical.computeDistanceBetween(viewportLatLngBounds.getCenter(), topCenterLatLng);
this.collection.radius = metersRadius / 1000;
this.collection.radiusUnits = "km";
Run Code Online (Sandbox Code Playgroud) 我在整个网站上使用Ember,甚至是静态页面.
我有一个设计api设置,使用user.new,user.login和user.edit来创建,登录或编辑现有帐户.
任何用户都可以去
http://hostname/user/edit
Run Code Online (Sandbox Code Playgroud)
看到编辑屏幕.我真的希望只有在用户登录时才能实现此目的.如果不是,那么该路由应该例如重定向到登录页面.
有没有办法做到这一点?
我差不多了,但我遇到了解码文件的问题.解码文件时不正确.
我用来上传文件的代码:
createDataSet: function() {
var data = new FormData();
data.append('original_filename', this.get('fileName'));
data.append('datafile', this.get('newData'));
data.append('project_id', this.get('content.id'));
data.append('name', this.get('content.name'));
$.ajax({
url: '/data_sets.json',
data: data,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
type: 'POST',
success: function(data) {
alert('ok');
},
error: function(xhr, data, errorThrown) {
alert('error');
}
});
}
Run Code Online (Sandbox Code Playgroud)
在Rails方面,我试图用以下方法来解决这个问题:
def create
# take care of the attachement
datasetfilename = Pathname.new(params[:original_filename]).basename
newfile = File.open(datasetfilename, 'w') do |f|
f.write(Base64.decode64(params[:datafile]))
end
@dataset = DataSet.new
@active_data_set = @dataset.active_data_sets.build
@active_data_set.project_id = params[:project_id]
@active_data_set.save
@dataset.name = params[:name] …Run Code Online (Sandbox Code Playgroud) 在javascript函数中,我调用服务器并获取10批记录.我需要这样做,直到我有所有记录.
为了开始,我做了一个while循环,在ajax调用的错误回调中,我将结束while循环.
中途我开始意识到这不起作用,因为ajax调用是异步的,因此我会在循环中激发大量请求.我确信有一个标准模式可以做到这一点,但我不知道如何.
如果调用没有返回错误,我怎样才能在循环中执行ajax调用并执行它?我正在构建的伪代码:
var stillRecordsAvailable = true;
while (stillRecordsAvailable) {
// get the next batch of records
$.ajax({
url: '/getrecords.json',
data: {data_set_id: dataset.id},
type: 'GET',
success: function(data, textStatus, xhr) {
// do something
},
error: function(xhr, textStatus, errorThrown) {
// nothing left to do
stillRecordsAvailable = false;
}
});
Run Code Online (Sandbox Code Playgroud)
谢谢你指点我正确的方向
ember.js ×3
leaflet ×2
ajax ×1
capistrano3 ×1
decode ×1
ember-router ×1
file-upload ×1
geocoding ×1
javascript ×1
jquery ×1
pagination ×1
toastr ×1