NicolasCARPi / jquery_jeditable

jQuery edit in place plugin. Extendable via plugin architecture. Plugins for plugin. Really.
https://jeditable.elabftw.net
MIT License
1.74k stars 458 forks source link

Select - Default value by current value selected #228

Closed stemaste62 closed 3 years ago

stemaste62 commented 3 years ago

Hi, I use this code: https://codepen.io/stemaste/pen/mdOKRWP

the example codepen not work because the ajax page not exixsts in example, but I assure you that it works regularly except that I cannot pass the current selection to works.php so that it returns me the correct values in json for example: {'ART':'Artist','BLD':'Builder','FRM':'Farmer','selected':'BLD'}

I would like to pass the id because so I can see what is written in the db. Or is there some other way?

I tested value: but without success, i tried to insert a function in loadurl: but it is not supported apparently

any idea? Thank you for nay help

NicolasCARPi commented 3 years ago

If I understand correctly, you want to pass the id of the currently selected value to works.php?

Why don't you grab that id and send it in your query by using a function target instead of the url string.

See:

// target as a function example
$(".editable-text-full").editable(function(input, settings, elem) {
    console.log(input);
    console.log(settings);
    console.log($(elem).data('test'));
}, {});
stemaste62 commented 3 years ago

Thanks for your time, but I'm afraid I don't understand. I have to send the current select before the new selection is made. When I recover the possibilities from the Json file, precisely. I saw that example in the manual, but I didn't understand how to make it work for me I think this is a basic functionality to use input select in a dynamic page. Instead it is so complicated ;-) sorry, but I'm not a very good programmer. Since the value of the input select does not appear in html, but only the value.text, the only way is to go and see what is written in the DB. For this I thought of sending the id directly to the program that generates the json file, because html id is id of db record for me.

https://intra.kiwynet.com/works.asp?q_act=READWORKS&q_id=845 https://intra.kiwynet.com/works.asp?q_act=READWORKS&q_id=572

another way to prepare a key in html span as optionvalue = "BLD" to be read by the function, it would be the best thing

do I tell lies?

stemaste62 commented 3 years ago

analyzing the function thoroughly I found that loadurl also sends a series of parameters including the id, so for me it is enough

qact=READWORKS&0=q&1=&2=i&3=d&4=%3D&5=5&6=7&7=2&pk=845&_=1614789130874

Thank you for any help

NicolasCARPi commented 3 years ago

ok great!