|
I did resolve it buddy, here it is:
{{#tag-input
tags=tags
addTag=(action 'addTag')
removeTagAtIndex=(action 'removeTagAtIndex')
as |tag|
}}
{{tag}}
{{/tag-input}}
|
|
|
|
|
const base = [
{id: 1,name: 'A1'}, {id: 11,name: 'A11'},
{id: 12,name: 'A2'}, {id: 111,name: 'A111'},
{id: 112,name: 'A112'}, {id: 121,name: 'A121'},
{id: 122,name: 'A122'},
{id: 2,name: 'A2'},{id: 3,name: 'A3'},{id: 4,name: 'A4'}
];
const tree = [
{id: 1, parent:0, level: 'L1'},
{id: 11, parent:1, level: 'L2'},
{id: 111, parent:11, level: 'L3'},
{id: 112, parent:11, level: 'L3'},
{id: 12, parent:1, level: 'L2'},
{id: 121, parent:12, level: 'L3'},
{id: 122, parent:12, level: 'L3'},
]
i have two object one is base another one is tree. if i pass the 'id=11' it has to remove the [id:11]'s level 'L2' and its top level 'L1' id from the base object and result the remaining values. the below result am expecting
const result = [
{id: 111,name: 'A111'},
{id: 112,name: 'A112'}, {id: 121,name: 'A121'},
{id: 122,name: 'A122'},
{id: 2,name: 'A2'},{id: 3,name: 'A3'},{id: 4,name: 'A4'}
];
how to achieve this?
modified 5-Sep-20 13:11pm.
|
|
|
|
|
Hi,
Tried so many things and nothing works.
It works in Edge but not in IE, is it possible at all?
Tried a lot of combination as suggested (location.href and window.location.href, replace etc.).
IE settings for redirection were allowed by default.
This was the last try:
if(!!navigator.userAgent.match(/Trident.*rv\:11\./))
{
window.location.href = "https://google.de";
window.location.reload();
}
modified 2-Sep-20 7:25am.
|
|
|
|
|
Just setting the location.href or using location.assign should work fine.
location.href = "https://google.de";
location.assign("https://google.de"); Location: href - Web APIs | MDN[^]
Location: assign() - Web APIs | MDN[^]
NB: Call one or the other, not both. And don't call reload afterwards, since that reloads the current page.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello,
that's weird. It doesn't work. I tested it in my IE (V 11.1016.18362.0) on my Windows 10 PC.
Could anybody confirm that it works in his IE?
I don't know how else to test it as in my browser.
modified 4-Sep-20 6:28am.
|
|
|
|
|
It's solved.
Had an Error Code caused by UrlSearchParam(?!). It prevented the website in IE to run the rest of the code. Thanks all.
|
|
|
|
|
|
I'm executing a function on onclientclick.
function GetUrlPage() {
var pplid = document.getElementById('<%= tbPersonId.ClientID %>').value;
var newwindow = window.open('MXUrl.aspx?PersonId=' + pplid, null,
"Width=475px, Height=500px; top=42px; scrollbars=1; toolbar=0; titlebar=0; menubar=0; status ;");
Nothing happens. If I add an alert("some message"); after the window.open everything works great.
I can only assume it is just blowing thru the code but I don't know how to make it wait.
Don't do much in javascript so am really at a loss. Really appreciate any help you can give me.
|
|
|
|
|
Most likely it is scope issue. You create the local variable newwindow inside the function. So as soon as you exit the function that variable is destroyed and its corresponding window with it. Put the variable outside the function so it will exist for as long as it is needed.
|
|
|
|
|
Thanks for the reply but unfortunately no luck. I tried setting focus to the new window. Checked for document readystate. Only thing that works is adding an alert after the window.open. What's really baffling is that I have this same exact code in multiple places with the same project and it works flawlessly. Truly at a loss.
|
|
|
|
|
Sorry, I cannot offer any suggestions, other than using the debugger to trace what is happening.
|
|
|
|
|
I will. Thanks for responding.
|
|
|
|
|
I changed the call from Window.open to Response.Redirect and it worked fine. Not what I want to do but the only solution I could find.
|
|
|
|
|
That suggests to me that you're trying to open a new window as soon as the current page loads. Most browsers will block popups which aren't launched as the direct result of user interaction - eg when the user clicks a button.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Ok, first please have pity/patience with me as I'm just starting to learn coding. I'm following a course on Udemy to learn JS and on one part im not getting the same result as shown on the video- maybe some kind of wrong setting or something. Heres the code:
let car = {
make: "volvo",
speed: 160,
engine: {
size: 2.0,
make: "bmw",
fuel: "petrol",
pistons: [
{ maker: "BMW" },
{ maker: "BMW2" }
]
}
};
I know, simple, like toddler like simple but im just starting out. I open the live preview and i type car and im supposed to get all the details about the nested objects and array but all i get is this:
{make: "volvo", speed: 160, engine: {…}}
Nothing else. Any help?
THanks,
Dave
|
|
|
|
|
What do you mean by "all the details about the nested objects"? What output are you expecting? The reason you are seeing what you are seeing is because that's what "car" is, it is all of those properties. If you want to drill down to individual properties then you do that like
car.make
car.pistons[0].maker
car.pistons[1].maker
and so on.
|
|
|
|
|
First thank you so much for replying! I'd buy you a beer if i could. So according to the video the output should be :
car
object
engine: Object
fuel: "petrol"
make: "bmw"
pistons: Array [2]
0: Object
1: Object
Length: 2
_proto_: Object
size: 2
_proto_: Object
make: "volvo"
speed: 160
_proto_: Object
and there are little triangles in front of a few of the lines (in front of object, and pistons) to expand to see the details... The output I get has no triangle to expand. Ill try to take a screenshot so you can see what i mean... thanks is advance!
|
|
|
|
|
Are you pressing [ENTER] enough times? Seems a bit awkward but when you type "car" it will show you a list of things it thinks are valid with a ghosted preview of the data. When you type "car" then [ENTER] you are confirming "car" as a selection from the auto list. When you press [ENTER] again you are submitting it as a command, and it is then you see the proper representation of the data which will have the clickable arrows.
|
|
|
|
|
OMG that was all it was I feel so stupid lol. Thank you so much for your help! You're awesome.
|
|
|
|
|
|
var dataJSON = {
"Name": "Group1",
"Description": "Test Desc",
"Countries": [
{
"Id": "188b985",
"Name": "USA",
"states": [
{
"state": "California",
"stateNumber": 1,
"neighbouringStates": [ "Oregon", "Neveda" ]
}, {
"state": "North Carolina",
"stateNumber": 9,
"neighbouringStates": [ "Virginia", "Georgia" ]
}
]
}, {
"Id": "218b985",
"Name": "Canada",
"states": [
{
"state": "Alberta",
"stateNumber": 21,
"neighbouringStates": [ "British Columbia", "British Columbia" ]
}, {
"state": "Ontario",
"stateNumber": 92,
"neighbouringStates": [ "Manitoba", "Quebec" ]
}
]
}
]
};
var excludeKeys = ["Id", "stateNumber"];
Looking for help with
making a copy of the dataJSON By eliminating the keys from excludeKeys collection.
iterate recursively/loop through dataJSON to a single object with all the nested keys and values.
After flatten, the keys should be something like this
{
"Name": "Group1",
"Description": "Test Desc",
"Countries1/Id": "188b985",
"Countries1/Name": "USA"
"Countries1/states1/state": "California",
"Countries1/states1/stateNumber": 1,
"Countries1/states1/neighbouringStates": [ "Oregon", "Neveda" ],
"Countries1/states2/state": "North Carolina",
"Countries1/states2/stateNumber": 9,
"Countries1/states2/neighbouringStates": [ "Virginia", "Georgia" ],
"Countries2/Id": "218b985",
"Countries2/Name": "Canada",
"Countries2/states1/state": "Alberta",
"Countries2/states1/stateNumber": 21,
"Countries2/states1/neighbouringStates": [ "British Columbia", "British Columbia" ],
"Countries2/states2/state": "Ontario",
"Countries2/states2/stateNumber": 92,
"Countries2/states2/neighbouringStates": [ "Manitoba", "Quebec" ]
};
|
|
|
|
|
Try something like this:
function flatten(target, object, prefix){
if (Array.isArray(object)){
object.forEach((value, index) => {
flatten(target, value, prefix === "" ? (index + 1).toString() : prefix + (index + 1));
});
return;
}
if (typeof object === "object"){
Object.keys(object).forEach(k => {
flatten(target, object[k], prefix === "" ? k : prefix + "." + k);
});
return;
}
target[prefix] = object;
}
var dataJSON = { ... };
var merged = {};
flatten(merged, dataJSON, "");
alert(JSON.stringify(merged, null, 4));
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello,
i have a static website (Jekyll generated). When the page loads, i'm making an AJAX call and set the values for the input fields in the "(function($){$(function(){});" block. as follows:
document.getElementById("email").value = email;
But i can't set the dropdown value, tried the following:
document.getElementById("calender_number").selectedIndex = value.toString();
document.getElementByValue("calender_number").selectedIndex = value.toString();
$('#calender_number').val(value.toString());
This one works in document ready but not after the AJAX call:
$('#calender_number').val(value.toString());
I also tried a post render technique from here:
https://www.daftlogic.com/information-programmatically-preselect-dropdown-using-javascript.htm
Best regards
modified 22-Aug-20 19:28pm.
|
|
|
|
|
selectedIndex is a number representing the zero-based index of the selected item. You can't set it to the value you want to select.
If you want to update the control with pure Javascript, you should be able to set the value instead:
document.getElementById("calender_number").value = value.toString(); The jQuery option should also work fine. There's probably something else wrong with your code - for example, have you waited for the AJAX call to complete before trying to update the controls?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
i inserted it in a .done block instead of .success, if you mean that?!
I set the value directly with a number but nothing works. So i assume it has nothing to do with static websites in general but more with the template (Materialize:Github).
Tried to add the attribute "selected" with js but it's ignored.
|
|
|
|
|