i want to update list selector items dynamically .i am set the list selector widget like following
this.ConversionToNumaric= [ {label:$L('One'), value:"1", secondaryIcon:''},
{label:$L('two'), value:"2", secondaryIcon:''},
{label:$L('three'), value:"3" , secondaryIcon:''}
]
this.controller.setupWidget('listSelectorConversionToNumaric', {labelPlacement:'left',label: $L('To'), choices: this.ConversionToNumaric, modelProperty:'currentConversionToNumaric'}, this.selectorsModel);
the above code i am using for setup the widget
this.ConversionToNumaric= [ {label:$L('four'), value:"4", secondaryIcon:''},
{label:$L('five'), value:"5", secondaryIcon:''}
]
]
this.currentConversionToPower.choices=this.ConversionToNumaric;
this.controller.modelChanged(this.currentConversionToNumaric);
what mistake i made here i don't know but it is not updating please help me
i got solution.i am not updating the model i am updating something else
that's way i got problem. i resolved this one by using this.selectorModel
this.selectorsModel=this.ConversionToNumaric; this.controller.modelChanged(this.selectorsModel);
Related
I'm trying to dynamically build an action link for adding items to a database in Laravel. The problem is that I need to pass a parameter with category_id, which I only get after selecting the category in html select element.
I thought about using the even onChange() on select element, and then building up the link in js function, and finally setting it to "a" element with the help of js selector. However this approach doesn't work.
var link = "{{ action('ItemController#create', [ 'id' =>"+selectedId.value+"]) }}";
document.getElementById("AddItemLink").href = link;
Is producing: http://localhost:8000/item/create/+selectedId.value+
What I need to get is: http://localhost:8000/item/create/8
If I do console.log(selectedId.value), the output is correct - 8.
Any ideas how to deal with this?
You can do that,
var link = "/item/create/"+ selectedId.value;
document.getElementById("AddItemLink").href = link;
I am using try in Laravel 5.5 like this...
try {
$fruit = Fruit::findOrFail($id);
}
But I would like to check that not only that it finds the Fruit with the supplied ID but that it also has a fruit_color of 'red'
Do I need to do this with a 'with' statement?
I know I can run another check afterwards but wondered if I could do this all in one statement?
A few things. First, throwing an exception here is the wrong way to handle the ‘if’ situation. If you plan on a situation where a value isn’t return, then this isn’t the proper use of an exception. To answer your question:
$fruit = Fruit::where(‘id’, $id)->where(‘color’, ‘red’)->get();
This returns a collection of items meeting your criteria. Next to test if the collection is empty (no fruit) you can do the following:
if($fruit->isEmpty()) {
//handle empty collection
}
Hope this helps! The Laravel documents for collections kicks a**. I’d recommend reading further there.
You just need to add your extra conditions in before you call the find:
try {
$fruit = Fruit::where('fruit_color', 'red')->findOrFail($id);
}
Try this code
$fruit = Fruit::where(‘id’, $id)->where(‘color’, ‘red’)->first();
I have a dropdown menu in d3.js, and I would like to get the index from the selected option. It's a list of a bit more than 50 flight companies, and right now I have this :
function choixCompagnie(){
let compagnieChoisie = d3.select(this).property('value')
}
This function activates whenever there is a change on the drop down, like so :
d3.select("#selectCompagnie")
.on("change",choixCompagnie)
The property('value') means that for instance if I click the first line of my drop down menu, which is Aer Lingus, my compagnieChoisie variable will get the value Aer Lingus instead of 0.
I need it because I then need to access some properties company by company, and my objects are in an array. So in my database I need to access the properties like this data[index].randomProperty and not like this data["Company Name"].randomProperty, since the company name is already a property.
I don't know if this makes sense, sorry if I'm using the wrong terms I'm fairly new to coding.
Thanks for the help !
edit : here is a working example http://blockbuilder.org/ArnaudStephanUNIL/a18332a561579eb929091faaff91fb6f, where the drop down gets the value but not the index
You should access your data like this:
function choixCompagnie(){
let compagnieChoisie = d3.select(this).property('value')
console.log(data.find(d => d.compagnie === compagnieChoisie).accidents);
}
I found a better, easier way to get the index from a drop down menu :
<select id="selectOptions"></select>
Once you initialized your drop down menu, you simply have to do this :
var options = ["option1","option2"];
options.forEach(function(d,i){
d3.select("#selectOptions")
.append("option")
.attr("value",i)
.text(d);
})
I would like to track some backend-changes in the cloud.
The log of my before_save tells me something like this:
before_save triggered for Elements for user oKwM9mvEUn:
Input: {
"original":
{"elements":[
{"__type":"Pointer","className":"Element","objectId":"VzeuG3Z5N6"},
{"__type":"Pointer","className":"Element","objectId":"APkHJpgcms"},
{"__type":"Pointer","className":"Element","objectId":"xHG1jg8fny"}
]},
"update":
{"elements":[
{"__type":"Pointer","className":"Element","objectId":"VzeuG3Z5N6"},
{"__type":"Pointer","className":"Element","objectId":"xHG1jg8fny"}
]}
}
Result: Update changed to
{"elements":[
{"__type":"Pointer","className":"Element","objectId":"VzeuG3Z5N6"},
{"__type":"Pointer","className":"Element","objectId":"xHG1jg8fny"}
]}
The dirtyKeys tells me that "elements" has been changed, but I would like to know what exactly has been added (or removed) because I only like to track the changes...
Is there a possibility to access those "update" values? Or do I have to track it by myself in an other property?
Thanks for a hint!
As I posted on a similar question, you can get relation change details using:
request.operation.op(yourFieldName)
That returns a Parse.Op.Relation object.
Am trying to set a product category on different collections but only the last collection defined in docpad.coffee actually sets it when trying it like so
firstCollection: ->
#getCollection("html").findAllLive().on "add", (model) ->
model.setMeta({category: 'first'})
secondCollection: ->
#getCollection("html").findAllLive().on "add", (model) ->
model.setMeta({category: 'second'})
document.categorywill be 'second' for all documents of each collection.
How to set the same meta data individually per doc in a collection?
What problem are you trying to solve? Because your approach is not going to work. If you share what you're trying to do, we may be able to suggest an alternative approach.
Your current approach won't work because you are setting a metadata property named "category" that is a string. That metadata property lives on the documents in the collection and not on the collection itself.
Both collections are pointing at the same set of documents. Each individual document can only have a single value for that property. It can't be both 'first' and 'second'. The last one to set it wins, and in this case, the event that sets it to 'second' is happening last and so all of the documents have 'second' as the value for that metadata property.
Update: I found a better way to do this: model.setMetaDefaults({foo:'bar'})
For example, to create a blog collection with a default cssClass of post:
collections: {
blog: function() {
return this.getCollection("documents")
.findAllLive({relativeOutDirPath:'blog'}, [{filename:-1}])
.on("add", function (model) {
model.setMetaDefaults({'cssClass': 'post'})
});
}
},
This would go in your docpad.coffee file or, in my case, docpad.js.
See a working example with full context at https://github.com/nfriedly/nfriedly.com/blob/master/docpad.js#L72 (collection is called "techblog", starts around like 72).