Compare commits
No commits in common. "9e414613594e48e63cf34dedede04e8297b095e7" and "a476ab2f347a99a59b55c537f4b5190ec41342e5" have entirely different histories.
9e41461359
...
a476ab2f34
5
app.py
5
app.py
@ -219,11 +219,6 @@ def habit_create():
|
|||||||
errors=errors,
|
errors=errors,
|
||||||
)"""
|
)"""
|
||||||
|
|
||||||
@app.route('/check', methods=['POST'])
|
|
||||||
@login_required
|
|
||||||
def check_habit():
|
|
||||||
habit = request.get_json()["habitId"]
|
|
||||||
return {}
|
|
||||||
|
|
||||||
# Run the application
|
# Run the application
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@ -85,7 +85,7 @@
|
|||||||
{% for habit in habits %}
|
{% for habit in habits %}
|
||||||
<li class="row col-md-4">
|
<li class="row col-md-4">
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<input type="checkbox" class="task-checkbox" id="{{habit.id}}" onclick="sendPostRequest('{{habit.id}}')">
|
<input type="checkbox" class="task-checkbox" id="{{habit.id}}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
|
<div class="col" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
|
||||||
@ -101,33 +101,6 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
|
||||||
function sendPostRequest(checkboxId) {
|
|
||||||
// Get the checkbox element using the provided ID
|
|
||||||
var checkbox = document.getElementById(checkboxId);
|
|
||||||
console.log(checkbox);
|
|
||||||
// Check if the checkbox is checked
|
|
||||||
if (checkbox.checked) {
|
|
||||||
// Get the habit id from the checkbox id attribute
|
|
||||||
var habitId = checkboxId;
|
|
||||||
|
|
||||||
// Make a POST request to /check with the habit id
|
|
||||||
axios.post('/check', { habitId: habitId }, {
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(function (response) {
|
|
||||||
// Handle the success response if needed
|
|
||||||
console.log(response.data);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
// Handle the error if needed
|
|
||||||
console.error('Error:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Loading…
x
Reference in New Issue
Block a user