In the label we have item.ID + '-'+ item.Description
the value is item which is the object returned from the service.
When a selection is made 001-MyChoice for ex. from the autocomplete, the value which is the datacontract object is bound to the autocomplete field as [Object object]. How can I get 001-MyChoice to be bound for the selection ???
Pls help..
It's difficult to tell when you haven't posted any code to review. What format is your data returned from the service? JSON, XML?
I'm sure you're already looked at this link, but here it is just in case:
http://jqueryui.com/demos/autocomplete/#remote
Post some sample code of your js and some sample data of what your service returns for a better answer.
The autocomplete tags returned from your web service need to contain the tag 'term' and I think "ID", then the default call can help pull them out. Although not a perfect example if you look at the Jasonp example in the jQueryUI docs, that may help.
This is from memory but something like
{"term":"dog", "ID": "123"}, {"term":"cat","ID": "2"}
So you have 001-MyChoice as the label and you want it bound as the value?
Then don't specify the object returned as the value. Label and value are not required by the autocomplete. You can specify both if you want one in the dropdown select (label) and the other (value) used as the value of the select.
If you want the select item and the value to be the same, then put the same item in either the label or the value property.
From the jquery autocomplete docs:
The label property is displayed in the suggestion menu. The value will be inserted into the input element after the user selected something from the menu. If just one property is specified, it will be used for both, eg. if you provide only value-properties, the value will also be used as the label.
If you need to use the datacontract object, then just assign it to a variable in the select callback function of the autocomplete and you can use it as that.
Related
I have an event-based rule configured to fire on click of an element with a specific class. On click, I would like to capture the value of a data attribute that exists. The DTM documentation says you can capture attribute values using this syntax:
%this.data-event%
or
%this.id%
Example HTML:
On click of links with the class "test", I would like to store the value of "event name" within an eVar. When I used the above syntax however, the syntax is converted to a string and in the Adobe server call as:
v25:%this.data-event%
What is the best way to dynamically grab the value of an attribute of an HTML element on click within DTM?
DTM documentation says you can do that, but in practice I too have found that it doesn't seem to work as advertised most of the time, and will instead populate it with a literal (un-eval'd) string like that.
So what I do instead is under Conditions > Rule Conditions I create a Custom condition. In the Custom condition, I add the following:
// example to get id
_satellite.setVar('this_id',this.id);
// example to get href
_satellite.setVar('this_href',this.href);
return true;
Basically I create on-the-fly data elements using javascript, and then return true (so the condition doesn't affect the rule from triggering).
Then I use %this_id%, %this_href%, etc. syntax from the data element I created, in the Adobe Analytics section variable fields.
The easist way to capture the values of a data attribute against an eVar or prop on the element clicked using DTM is to set the input as the following:
%this.getAttribute(data-attributename)%
For example, if there was a data attribute on an element of data-social-share-destination='facebook' simply input %this.getAttribute(data-social-share-destination)%. This will then capture the value of 'facebook'
More detail on data attributes can be found at http://www.digitalbalance.com.au/our-blog/event-based-tracking-using-html5-custom-data-attributes/
I found a solution. The best way to grab the value of an attribute on click is to use this syntax:
%this.getAttribute(data-title)%
The key is to not use quotes around the attribute name AND ensure the attribute has a value.
If the attribute is missing, the expression is not replaced by an empty string as one would normally expect from experience in other platforms, but instead will display the raw un-interpolated code.
I've an array of objects containing title and salary which is used in typeahead directive.
I display department name and get entire object as value.
If none of the options match, I want user entered string to be converted to object still. Is there any way to update that?
This answer is pretty late, but I would just use ng-blur (to trap the end of the users input) along with a variable bound to typeahead-no-results. Then test if the variable is true in the method bound to ng-blur, and, if so, make an object out of the String supplied by the user and push it to your data source. Simple example found here.
I have a select multiple on my page. The user can add elements to the list and remove them selecting one or more.
When I get the select's value through params.selectName, I receive only the selected ones. I
understand that this is the default behavior, but I need all of them, not only selected elements.
I don't really want to select all elements each time I send data to server. Does anyone have a better solution? Thanks.
The approach taken by the <g:checkBox> tag is to create a hidden field with the same name as the checkbox but with an underscore prepended. You could use a similar trick here, i.e. whenever you add a new <option> to the <select> you also add a hidden field named (say) selectName_options with the same value. Then in the controller you can take the difference between params.list('selectName') and params.list('selectName_options') to get the un-selected options from the list.
This is a bit of a complex solution to what should be a simple problem, but in my current project we just had the same problem and solved it as #cdeszaq describes.
Assuming an object of class Foo with a collection (bars) of Bar items, where each Bar has a String name and outputs it as its toString() representation, we do this in the FooController:
def removedItems = fooInstance.bars.findAll {
!params.bars.collect { it.key }.contains(it.name)
}
if(removedItems){
removedItems.each {
fooInstance.removeFromBars(it)
}
}
I'm using a EntityDataSource with WhereParameters binded from DropDownLists. The Where Clause may be something like this: "it.applicationId = #applicationId" but in that DropDownList i've created a ListItem with Text="All" Value="".
Of course that when the value is "" i don't want to use that value on the query.
How can i do that?
Thank U All
It looks like there is no design time possibility to use parameters optionally.
Try hooking the Selecting event, like it is described in this question.
In your particular case you can get the selected value of the DropDownList (for example, using the FindControl method) and then simply either pass the value of the parameter, or use the query without a Where clause.
you should at first set the attribute "ConvertEmptyStringToNull" in your parameter to true
then type your where condition as follows
"#applicationId IS NULL OR it.applicationId = #applicationId"
I'm trying to access the values in the FormCollection inside of an action. I can get the value field by doing:
var value = formCollection["MyDropDownList"];
But I can't seem to find a way to get the display value. Am I missing something obvious? A cast perhaps?
Getting text from an HTML drop down selection list using JavaScript code
To get the text from each option is slightly trickier. We use the selectedIndex property of the selection list to capture the selected option and then pass this value to the options[].text property.
Here is the code
var w = document.myform.mylist.selectedIndex;
var selected_text = document.myform.mylist.options[w].text;
I don't think there's a way to get the display column from the formcollection. Basically, the formcollection is an easy way to interrogate the Request object (Request.Form, Request.QueryString, etc.) and the only thing that goes into that are values from input fields.
If you really need to get the display text, you would have to get it from whatever collection you bound the list with and access it via the key (your selected value from the formcollection). For example, if it's a dictionary collection that you bound to the list, use that same dictionary to lookup the value based on the key.
I would need to know more information as to how you're binding the dropdown to help you further.
That's the normal behaviour. When a form is posted, only the name-value collection generated from the form fields are sent to the server. And of course the inner text of the option tag doesn't belong to that collection.
you do it ok, dropdown list sended shows value of selected item not displayed text of selected item...if you want(from some reason, because I am asumming you are filling that dropdown on model right? :)) to see send a display text also, maybe you can put it in hidden field with javascript on every change of selection in dropdown...
cheers