Two textblocks after each other
Tag : xaml , By : Doc Immortal
Date : March 29 2020, 07:55 AM
this will help I have two textblocks and they are after each other on the page - name & surname. I am binding data to this so the size depends of the length of them. What's the best way to do them working with variable size? <StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding FirstName}" Margin="0,0,5,0" />
<TextBlock Text="{Binding LastName}" />
</StackPanel>
|
How to search multiple files for textblocks and write those textblocks to another file
Tag : python , By : Bobblegate
Date : March 29 2020, 07:55 AM
To fix this issue Here is an example of an input file: , Here's a start: import os, re
path = 'C:/Temp/Folder1/allTexts'
listing = os.listdir(path)
for infile in listing:
text = open(path + '/' + infile).read()
match = re.search('<div id="text-interesting1">', text)
if match is None:
continue
start = match.start()
end = re.search('<div id="text-interesting2">', text).start()
print text[start:end]
|
loop through an array one time to populate an iFrame then go to another page when loop is finished
Date : March 29 2020, 07:55 AM
should help you out This code will show them one by one, showing the next one when you click the button. <!DOCTYPE html>
<html>
<body>
<button id="nextButton">NEXT!</button>
<iframe id="frame1"></iframe>
<script type="text/javascript">
var lastloaded = 0;
window.onload = loadPages;
function loadPages () {
var frame = document.getElementById("frame1");
var arr = ["aCard.html", "bCard.html", "cCard.html", "dCard.html"];
if (lastloaded+1>arr.length){
lastloaded = 0;
}
frame.src = arr[lastloaded];
lastloaded++;
}
document.getElementById('nextButton').onclick = loadPages;
</script>
</body>
</html>
|
Populate javascript variable in loop to use for icon definition outside loop
Date : March 29 2020, 07:55 AM
help you fix your problem The html option of your numberIcon object is assigned the value of number at creation, i.e. before your loop. So html is undefined. This assignment is not re-evaluated later on, so it remains at undefined, no matter what the variable number becomes. You could try re-assigning directly the html option within your loop (numberIcon.options.html = '11'), so that if your marker creates its icon right away, it will use an updated value of html. However, as pointed out by user 6502, all your markers now use the exact same icon object. So if for some reason, one of the marker needs to re-create its icon element (this happens for example when the marker is removed from map and added back), it will read the last value of html, which is probably not what you want.
|
How to loop thorugh mongoDB with a promise and a forEach loop? I want to populate an Array
Date : March 29 2020, 07:55 AM
will help you You need to render it after the Promises all resolve using Promise.prototype.all, there's no other way to get the populated productsArr array. Try this: //shopController.js
const Product = require('../models/product');
const User = require('../models/user');
exports.getCart = (req, res, next) => {
const productIds = [];
// const productsArr = []; not needed anymore
let userData = null;
User.findById(req.user._id)
.then(user => {
userData = user;
userData.cart.items.map(prodId => {
productIds.push(prodId.productId);
})
console.log(productIds); // [ 5dc1b6ace13a97588620d6c6, 5dc1b6ace13a97588620d6c6 ]
return productIds;
})
.then(prodIds => {
Promise.all(prodIds.map(prodId =>
Product.findById(prodId)
).then(productsArr => {
res.render('shop/cart', {
path: '/cart',
docTitle: 'Cart',
products: productArr,
userData: userData
});
console.log(productsArr); // [ ... products ... ]
}).catch(err => {
console.log(err);
})
})
.catch((err) => {
const error = new Error(err);
error.httpStatusCode = 500;
return next(error);
});
}
|