Who Can Solve This Problem Pls - Webmasters - Nairaland
Nairaland Forum › Science/Technology › Webmasters › Who Can Solve This Problem Pls (1009 Views)
| Who Can Solve This Problem Pls by cbrass(op): 4:03am On Jul 07, 2015 |
this thing has been freaking my arse out since yesteday. what am trying to do is use a pop up to edit a post on a page, please note that the posts were pulled out of a db which means they have ids assigned to them. am using a modal to create a pop up but my issue is pulling the exact post when the edit button is clicked, i know if i call it with the id it will appear successfully but knowing where to put the id in other to refernce it is my problem , this is my code <div class="modal fade" id="modal-form" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">cc adewasco2k dhtml18 onyegbu |
| Re: Who Can Solve This Problem Pls by cbrass(op): 4:15am On Jul 07, 2015 |
I forgot to add the hurry part sha, my jquery knowledge isn't sound enough ![]() |
| Re: Who Can Solve This Problem Pls by maekhel(m): 7:09am On Jul 07, 2015 |
First of all where is $postID coming from? |
| Re: Who Can Solve This Problem Pls by dwebdesign(m): 8:12am On Jul 07, 2015 |
maekhel: |
| Re: Who Can Solve This Problem Pls by adewasco2k(m): 8:21am On Jul 07, 2015 |
All you need is the HTML5 data attribute add this data-id="$id" to the post you are editing then you can use element.getAttribute('data-id') to get the id of the post. i dont really understand your question but this will help |
| Re: Who Can Solve This Problem Pls by cbrass(op): 9:32am On Jul 07, 2015 |
adewasco2k:What am trying to do is when users click on the<a href=> edit link </a> it should pop up. The window of that post but when I did it it just picked any post and not the actual post that has the edit link. Of course I know why it's doing this but how to fix it is what I don't know yet or do you have a code for pop ups |
| Re: Who Can Solve This Problem Pls by cbrass(op): 9:33am On Jul 07, 2015 |
maekhel:From a previous code above |
| Re: Who Can Solve This Problem Pls by maekhel(m): 9:50am On Jul 07, 2015 |
cbrass:Why not attach the post id to the edit link then use the id in your where clause in your update query |
| Re: Who Can Solve This Problem Pls by cbrass(op): 12:16pm On Jul 07, 2015 |
maekhel:That will only work if I want to redirect to another page but it's a pop up containing a textarea below that I want to use I don't want ppl to go to another page. You know like Facebook edit where you stay on your timeline when you be ant to modify a post |
| Re: Who Can Solve This Problem Pls by onyengbu: 3:14pm On Jul 07, 2015 |
cbrass:I am on mobile and can offer very limited help here. However, your issue have a very very simple solution. Since you are using query, there a lot of possibilities. You can just use add an attribute to the a href link that launches the modal box. By attribute I mean id, rel, class or even non HTML imagined ones that is only if you have ran out of standard HTML attributes for that element. JQuery will recognize it. Let's say you added an attributed named ahr to the link, and the link looks like this: <a href="javascript:void(0)" ahr="23">Edit</a>, you can create a variable from it in jquery like this: var thisID = $(this).attr("ahr" ;With this, you can then use query load() to load the db returned values specific to the query variable - thisID into the text area or content editable div where you can modify the db content and then send back via query/ajax request. I will create a complete sample code when I get to a PC. |
| Re: Who Can Solve This Problem Pls by cbrass(op): 4:15pm On Jul 07, 2015 |
maekhel:Yea... am beginning get the idea nw thanks |
| Re: Who Can Solve This Problem Pls by cbrass(op): 4:16pm On Jul 07, 2015 |
onyengbu:Am very greatfull sir, thanks alot |
| Re: Who Can Solve This Problem Pls by onyengbu: 7:14am On Jul 08, 2015 |
cbrass:Good. Have you done it? |
| Re: Who Can Solve This Problem Pls by cbrass(op): 9:49am On Jul 08, 2015 |
onyengbu:Not yet because I already moved to other things, that one was taking too much of my time but with what I see there I have a clue to how I should fix it however I don't mind if you post the solution you promised. |
| Re: Who Can Solve This Problem Pls by DualCore1: 10:22am On Jul 08, 2015 |
I didn't read your codes so I'm going to answer you based on the problem you have stated. For the list (psuedocode) create an iteration through your db records <foreach> <a href="your_file?id=$record_id">Edit Post</a> </foreach> For the modal window, pull the post from the db where ID = the "id" GET variable. Add the "id" GET variable as a hidden input type in the form and in the file that processes the DB update, retrieve the hidden attribute through POST. You should look at this plugin http://vitalets.github.io/x-editable/ See how it can be implemented, check one of my past projects: http://sawyerrken.net/projects/dreni/ username: admin password: admin Once logged into the dashboard, click on the "Bets" botton. Once in the bets page, click on any of the values in blue to edit then and see how it works. |
Domainking: Voguepay Problem. Pls HELP • Is This Problem From My Firefox Or Google? (pic Attached) • Php/mysql Gurus, Please Help Solve This Problem... • 2 • 3 • 4
10 Best Web Browsers For Android Device. • I Want Someone Who Can Make A Website Like Konga • My First Topic

;