Compare commits
2 Commits
a476ab2f34
...
9e41461359
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e41461359 | |||
| 4bc17623bb |
5
app.py
5
app.py
@ -219,6 +219,11 @@ 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}}">
|
<input type="checkbox" class="task-checkbox" id="{{habit.id}}" onclick="sendPostRequest('{{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,6 +101,33 @@
|
|||||||
{% 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