How can I implement the onDeleteComplete, do I put inside the deletefile: request or outside?
I've used the complete method before and I tried to implement the onDeleteComplete the same way but I get no actions. Below is the code I've tried to use but it fails.
$('#jquery-wrapped-fine-uploader').fineUploader({
request: {
endpoint: '/Test.aspx'
},
deleteFile: {
enabled: true,
endpoint: '/Test.aspx'
}
}).on('onDeleteComplete', function (id, xhr, isError) {
alert('hi');
})
So I finally got it working with your suggestion.
Here my final code
$('#jquery-wrapped-fine-uploader').fineUploader({
request: {
endpoint: '/Test.aspx'
},
deleteFile: {
enabled: true,
endpoint: '/Test.aspx'
}
}).on('deleteComplete', function (event, id, name, responseJSON) {
alert('hi');
});
Use of callbacks when using the jQuery plug-in is well documented in both the examples/demos on fineuploader.com and in the documentation. There are two distinct places in the documentation where us of callbacks are mentioned: the callbacks readme page and in the callbacks section of the using the jQuery plugin readme page.
The "on" in "onDeleteComplete" in your code is redundant, it should be changed to .on("deleteComplete", ...). Also, the first parameter passed to all event handlers by jQuery is "event".
Please read the documentation, starting with the first page at http://docs.fineuploader.com/. Read the introductory info, then follow the path outlined based on your use case.
How about now?
$('#jquery-wrapped-fine-uploader').fineUploader({
request: {
endpoint: '/Test.aspx'
},
deleteFile: {
enabled: true,
endpoint: '/Test.aspx'
}
}).on('deleteComplete', function (id, xhr, isError) {
alert('hi');
});
Related
If a user types myURL/ or myURL/#/ or even myURL/#/foo they get to my index page.
But if they type myURL/foo, they get a 404. This is terrible. They should instead be redirected to /.
I am trying to implement this and am not having a lot of luck.
(function() {
'use strict';
angular
.module('myApp')
.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('index', {
name: 'index',
url: '/',
templateUrl: 'js/views/page1.html',
controllerAs: 'page1Controller',
data: { pageTitle: 'Main' }
})
.state('page2', {
name:'page2',
url: '/page2/:id',
templateUrl: 'js/views/page2.html',
controllerAs: 'page2Controller',
data: { pageTitle: 'page2' }
})
$urlRouterProvider.otherwise('/');
}]);
})();
I have looked at dozens of articles, and nowhere do I seem to be able find this simple case handled.
On the official docs it is mentioned that you can pass $injector and $location to the function otherwise.
Their example looks like this:
app.config(function($urlRouterProvider){
// if the path doesn't match any of the urls you configured
// otherwise will take care of routing the user to the specified url
$urlRouterProvider.otherwise('/index');
// Example of using function rule as param
$urlRouterProvider.otherwise(function($injector, $location){
... some advanced code...
});
})
What you can do to achieve your goal is to create a state, and whenever something it's not matched and enters otherwise fct, send it to that state.
$urlRouterProvider.otherwise(function($injector, $location){
$injector.get('$state').go('404');
});
I have not tested this but should work.
I have implemented a custom validation function using the example referenced in the SimpleSchema documentation for validating the uniqueness of a username. In the example, an asynchronous call is made and a custom validation message is displayed if the username is found to already exist.
There is a note, that indicates that if all of the form fields are valid, the form will be submitted, however user creation will fail due to the "unique: true" requirement specified in the schema. Here is the relevant portion of the code from the example docs:
username: {
type: String,
regEx: /^[a-z0-9A-Z_]{3,15}$/,
unique: true,
custom: function () {
if (Meteor.isClient && this.isSet) {
Meteor.call("accountsIsUsernameAvailable", this.value, function (error, result) {
if (!result) {
Meteor.users.simpleSchema().namedContext("createUserForm").addInvalidKeys([{name: "username", type: "notUnique"}]);
}
});
}
}
}
In my case, I have the code working where I am testing if an activation code is valid, I even get the interface to display the error, however since there is no other "schema" failure, the form submits, despite the invalid response... do I need to manually prevent form submission (i.e. using jQuery), or is there something in SimpleSchema I should use instead?
activationCode: {
type: String,
label: "Activation Code",
max: 200,
min: 10,
regEx: /^(?=.*[A-Z])(?=.*\d).+$/,
custom: function() {
if (Meteor.isClient && this.isSet) {
Meteor.call("validateActivationCode", this.value, function(error, result) {
if (result && !result.isValid) {
Clients.simpleSchema().namedContext("signupForm").addInvalidKeys([{
name: "activationCode",
type: "notValid"
}]);
return false;
}
});
}
}
}
Thank You
I'm using Angular UI Router and I need to send a parameter with the state.go method. Like this:
$state.go('myState', { redirect : true });
I also need to check that parameter in the event stateChangeStart. Like this:
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
//redirect parameter is not available here.
//should be in toParams right?
}
Edit: here's my statedefinition:
$stateProvider.state('customer.search', {
url: '/search',
views: {
"right-flyover#": {
templateUrl: 'customer/search/search.tpl.html',
controller: 'CustomerSearchCtrl'
}
},
data: {
pageTitle: 'Sök användare',
hidden: true
}
});
The ui-router will pass parameters which were defined for a state hierarchy - we are navigating to. Please check:
URL Parameters (cite:)
Often, URLs have dynamic parts to them which are called parameters. There are several options for specifying parameters. A basic parameter looks like this:
$stateProvider
.state('contacts.detail', {
url: "/contacts/:contactId",
templateUrl: 'contacts.detail.html',
controller: function ($stateParams) {
// If we got here from a url of /contacts/42
expect($stateParams).toBe({contactId: 42});
}
})
So, if you want to work with param redirect, your state should look like this:
$stateProvider.state('customer.search', {
url: '/search/:redirect',
...
});
then we can use:
$state.go('customer.search', { redirect : true });
and that would be part of $statePrams
But maybe you try to use sent options, not parameters:
$state.go(to [, toParams] [, options]) (cite:)
options
Object - If Object is passed, object is an options hash. The following options are supported:
location Boolean or "replace" (default true), If true will update the url in the location bar, if false will not. If string "replace", will update url and also replace last history record.
inherit Boolean (default true), If true will inherit url parameters from current url.
relative stateObject (default $state.$current), When transitioning with relative path (e.g '^'), defines which state to be relative from.
notify Boolean (default true), If true will broadcast $stateChangeStart and $stateChangeSuccess events.
reload v0.2.5 Boolean (default false), If true will force transition even if the state or params have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd use this when you want to force a reload when everything is the same, including search params.
And that would be then the third param (reload instead of redirect):
$state.go('myState', null, { reload: true });
I recently solved the problem by using cache attribute is stateProvider and set it to false
like
.state('home.stats', {
cache: false,
url:'/stats',
templateUrl: 'views/stats.html',
controller: 'StatsCtrl',
controllerAs: 'stats'
})
$state.go actually returns a promise, so you can do something like:
$state.go('myState').then(() => {
if (redirect) {
// do something
}
});
I realize this isn't a generalized solution to the problem which is what I was looking for as well, but it allowed me to get the job done. You could easily wrap this in a method on the $state object if you need to reuse the logic repeatedly.
I have a Kendo file upload call, here is the function:
$("#fileUpload").kendoUpload({
async: {
saveUrl: "/people",
autoUpload: true
},
multiple: false,
complete: onComplete
});
function onComplete(e) {
// The upload is now idle
dataSourcePerson.read();
}
This calls the play routes file which triggers this method in my controller:
public static Result create() {
// Do some stuff
return ok("Successfully loaded new users");
}
My problem is that the upload box shows failure and a retry option even though the upload was a success. What should my create() method return?
I figured it out, I needed to respond with:
return ok("{\"status\":0}");
I have looked over the doc and searched for forums but I can not seem to find an examples on how to implement the Initial File List functionality for fine-uploader.
Below is the script that I am using - works great but what I would like to do is to use the Initial File List function to populate the fineuploader with the existing files that have been uploaded during this session.
I have code that will return a json feed with the required files in an array format.
I just can ot figure out where our how to call the function to initalize.
Thanks in advance.
<script>
// Wait until the DOM is 'ready'
$(document).ready(function () {
$("#fine-uploader").fineUploader({
debug: true,
request: {
endpoint: 'upload.cfm'
},
session : {
endpoint: 'imageStatus.cfm',
refreshOnRequest:true
},
validation: {
itemLimit: 2,
allowedExtensions: ["jpeg", "jpg", "gif" , "png"],
sizeLimit: 5000000 // 5 MiB
},
messages: {
tooManyItemsError: 'You can only add 2 images'
},
deleteFile: {
enabled: true, // defaults to false
endpoint: 'upload_delete.cfm?uuid=',
method: 'post'
},
retry: {
enableAuto: false
},
scaling: {
sendOriginal: true,
hideScaled: true,
sizes: [
{name: "THUMB_XX", maxSize: 113},
{name: "FULLIMAGE", maxSize: 450}
]
},
});
});
</script>
I solved the issue.
ends up that I did a custom build of the JS files and did not include the status function.
rebuild the downloads and works like a charm.
thanks everyone for the help.
The initial file list feature is not a function that you call, per say, it is an option that you set in the client. More or less, all you need to set is the endpoint where the uploader can retrieve this list of files, and then have your server correctly process them.
The server response should be a JSON Array of Objects.
[{ name: 'foo.jpg', uuid: "7afs-sdf8-sdaf-7asdf" }, ... ]
The trickiest part is getting that list of files server-side, and you may want to ask some Coldfusion folks about how to do that.