jquery ui autocomplete - open event (handling no results) - jquery-ui

I wanted to use the open event to return "no results found" when ui == null but in firebug it looks like that even after the open event is fired the ui list is always empty even if there are results.
My source is an XML file
I'm attempting:
open: function(event,ui) {
if( ui.item == null ) {
console.log("no results");
}
}

Add to autocomplete.js:
if(retMatch.length == 0) {
var noResult = new Array();
noResult[0] = {
label: "No results found",
title: "No results found",
description: "Your search did not return any results. Please refine your search criteria. If you believe this message is in error please fill out a support case."
}
return noResult;
}
to:
$.extend

Related

Select2 with remote datasource dropdown show "searching... - undefined" and then "The results could not be loaded" after select

I use select2 4.0.5 with ajax. It work well if I search and select result on dropdown.
But after select one value on dropdown, if I reopen dropdown again (click on select2 object) dropdown show "searching... - undefined" and then "The results could not be loaded"
I have fixed it.
"searching... - undefined" : on templateResult i add check result.loading
templateResult : function (result) {
if (result.loading)
return "Searching...";
return result.text + " - " + result.description;
}
On dropdown reopen after select, I found ajax data params.term is blank when dropdown reopen. It fix by
ajax: {
...
data: function (params) {
var query = {
term: params.term || $('#CurrencyID').select2('data')[0].text
}
}

SharePoint 2010 "save conflict" message when editing list item with attachment

I have been trying to address an error generated in SharePoint 2010 that occurs when I update a list item that has a Microsoft Office document attached. If I make changes to the attached document (by clicking its link in the list item) and then attempt to save the list item I get the error message below.
save_conflict_error
I am trying to capture and deal with this error using the ItemUpdating event receiver
The receiver never catches the save conflict exception in the try catch.
I have tried everything that has been suggested in about 4 pages of google searches and I have run out of things to try. This is a last desperate attempt to find a solution (if there IS one).
Below is my code for the ItemUpdating event receiver.
public override void ItemUpdating(SPItemEventProperties properties)
{
try
{
base.ItemUpdating(properties);
using (SPSite site = properties.OpenSite())
{
using (SPWeb web = site.OpenWeb())
{
//determine list
if (properties.List.Title.ToLower() == "mytestlist")
{
web.AllowUnsafeUpdates = true;
this.EventFiringEnabled = false;
properties.List.Update();
} //endif
} //end using
} //end using
}
catch (Exception ex) {
{
//abort the update
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.ErrorMessage = ex.Message;
properties.Cancel = true;
} //end try
}
} //end function
Here is my Elements.xml file also.
elements_xml
Thank you in advance.
:)

409 http error in Couchbase lite in phonegap on iOS

I'm getting a 409 on PUT, POST and DELETE actions.
I have successfully created a database and have PUT one document successfully ONCE. I have tried local and "normal" documents. I haven't spend any focus on revisions but think it has to do with this. I only want to save and update this one JSON string in my app - thats it.
It's like I have created this one document to stay forever :-)
Will sample code help? I'm really only using Angular's $http.
On a side note: I need a save mechanism in phonegap that is html5 cache-clear resistent.
You need to check if your document exists first before you update it. that's why it worked the first time and not the second.
config.db.get( "myDocumentID", function(error, doc) {
if (error) {
if (error.status == 404) {
//document does not exist insert it
config.db.put( "myDocumentID", myDocument, function(error,ok) {
if(error) { alert( "error" + JSON.stringify( error ) } else {
alert("success");
}
} )
} else {
alert( "error:" + JSON.stringify( error ) )
}
} else {
//update your document
doc.my_new_key = "value";
config.db.put( "myDocumentID", doc, function(error, ok) {
if( error ) { alert( "error:" + JSON.stringify( error ) ) } else {
alert("success");
}
} );
}
} )

MIME error in ui5

I am trying to delete multiple lines from the table. But I am getting a mime error.
Please help me to resolve it.
eg: enter link description here
Thanks and Regards,
Vicky.
I changed your code a little bit so it can be running in JSBin.
The service http://services.odata.org/V2/(S(2pxev2v2zqtidlzbqzhncots))/OData/OData.svc/Categories does not support batch request for DELETE. See the response body. If you want to do multiple deletion, you can send multiple DELETE question one by one using ODataModel.remove
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code/>
<message xml:lang="en-US">
Content is unexpected for the Delete operation.
</message>
</error>
Also For submitBatch(fnSuccess?, fnError?, bAsync?), the document indicates:
{function} fnSuccess?
a callback function which is called when the batch request has been successfully sent. Note: There might have errors occured in the single batch operations. These errors can be accessed in the aErrorResponses parameter in the callback handler. The handler can have the following parameters: oData, oResponse and aErrorResponses.
You have to check the parameter aErrorResponses in the success function callback to see if there is any error occurred. See the following for batch delete and check error responses.
var indices = oTable.getSelectedIndices();
if (indices.length == 0) {
alert("Please Select a row to Delete");
return;
} else {
alert("selected " + indices);
var batchChanges = [];
for (var i = 0; i < indices.length; i++) {
var selectedRow = oTable.getRows()[i];
var selectedId = selectedRow.getCells()[0].getValue();
var selectedName = selectedRow.getCells()[1].getValue();
var del = m.createBatchOperation(
"Categories(" + selectedId + ")",
"DELETE"
);
batchChanges.push(del);
}
m.addBatchChangeOperations(batchChanges);
m.submitBatch(function(oData, oResponse, aErrorResponses) {
if (aErrorResponses.length > 0) {
alert(aErrorResponses[0].response.body);
} else {
m.refresh();
m.clearBatch();
alert("success");
}
}, function(err) {
alert("error occured");
});
}

show dialog for option submit data

i have one submit form.
i want if someone submit same data can show jquery dialog "This data already exists! Are you sure to input?"
Then select OK or CANCEL.
can you tell me the step that must i do?thanks.
Send an ajax request with data to server-side, and if data exist return some kind of errorcode. Then in ajax handler check for error, if it is present show message "Data already exist", if not show message "Data was added". Server-side should check for duplicates and insert new data as well.
If user select "ok" in "Data exists" dialog, send another request with parameter to suppress duplicate error.
Client:
$.post("server.php", { "data": somedata }, function(result) {
if (result.error && result.error == 1)
if (confirm("Duplicate data, continue?"))
$.post("server.php, { "data": somedata, "suppress": 1 }, function(result) {
alert("Data was added");
});
else
alert("Data was added");
}, "json"); // we accept result in json format, jQuery will process it into JS object
Server:
if (isset($_POST['data']) && $_POST['data'] != "") {
if ( check_duplicate($_POST['data']) // don't forget to implement this
&& $_POST['suppress'] != 1 )
return '{ "error": 1 }';
else {
insert_data($_POST['data']);
return '{ ok }'; // you can return empty string as well
}
}

Resources