我正在使用dropzone.js进行图片上传.
在我的coffeescript js文件中,我有dropzone的设置:
Dropzone.autoDiscover = false
dropzone = new Dropzone('#item-form',
maxFiles: 1
maxFilesize: 1
paramName: 'item[image]'
headers: "X-CSRF-Token" : $('meta[name="csrf-token"]').attr('content')
addRemoveLinks: true
clickable: '#image-preview'
previewsContainer: '#image-preview'
thumbnailWidth: 200
thumbnailHeight: 200
parallelUploads: 100;
autoProcessQueue: false
uploadMultiple: false)
$('#item-submit').click (e) ->
e.preventDefault()
e.stopPropagation()
if dropzone.getQueuedFiles().length > 0
dropzone.processQueue()
else
$('#item-form').submit()
return
return
Run Code Online (Sandbox Code Playgroud)
除了选项之外,如果有图像存在,单击表单上的提交按钮将处理图像,如果没有图像,则无论如何都会提交表单.
接下来是我的控制器(相关代码):
def create
@item = current_user.items.build(item_params)
respond_to do |format|
if @item.save
format.html { redirect_to @item, notice: 'Item was successfully created.' }
format.json { render :show, status: :created, …Run Code Online (Sandbox Code Playgroud) 我正在尝试如何获取Image(使用CollectionFS的文件)并将Image的Id插入到我的Items imageId字段中:
LIB /收藏/ items.js
Items = new Mongo.Collection("items");
Items.attachSchema(new SimpleSchema({
name: {
type: String,
label: "Name",
},
userId: {
type: String,
regEx: SimpleSchema.RegEx.Id,
autoform: {
type: "hidden",
label: false
},
autoValue: function () { return Meteor.userId() },
},
image: {
type: String,
optional: true,
autoform: {
label: false,
afFieldInput: {
type: "fileUpload",
collection: "Images",
label: 'Select Photo',
}
}
},
imageId: {
type: String
}
}));
Run Code Online (Sandbox Code Playgroud)
LIB /收藏/ images.js
if (Meteor.isServer) {
var imageStore = new …Run Code Online (Sandbox Code Playgroud) Meteor.js和Materialise CSS Framework的新功能.我不完全理解如何动态地将Tabs连接到3个不同的选项卡,因此当用户单击它时,.tab indicator/ activeproperty将与所需的路径路径一起滑动.如果我这样做:
客户机/ app.html
<template name="tabs">
<ul class="tabs nav-tabs hide-on-med-and-down">
<li class="tab col s4" id="nt1"><a href="/page1">Page One</a></li>
<li class="tab col s4" id="nt2"><a href="/page2">Page Two</a></li>
<li class="tab col s4" id="nt3"><a href="/page3">Page Three</a></li>
</ul>
</template>
Run Code Online (Sandbox Code Playgroud)
客户机/ app.js
Template.layout.rendered = function() {
$('ul.tabs').tabs();
}
Run Code Online (Sandbox Code Playgroud)
选项卡指示器有效但不会更改指向正确页面的链接.它就像它阻止了去页面的能力.我需要帮助来解决这个问题,我已经有一段时间了.谢谢.