jquery-flexdatalist
jquery-flexdatalist copied to clipboard
Cannot automatically or manually set value of input
@sergiodlopes
I tried to automatically set the value of inputs by specifying their value attribute before initializing flexdatalist:
<input class="flexdatalist" value="1" ... />
and I tried to set them manually using JavaScript:
document.querySelectorAll('input.select').forEach( (element) => {
$(element).flexdatalist( 'value', element.dataset.value );
})
But no avail. I feel like these issues are connected.
I am using version 2.1.4
ever tried with latest version?
@nhaberl 2.1.4 is the latest version.
no 2.2.4 ... there are some major changes
@nhaberl Why isn't the NPM package being updated then? https://www.npmjs.com/package/jquery-flexdatalist
I have downloaded it manually, don't know 22:24, 22. April 2018, "Jonas Hübotter" [email protected]:@nhaberl Why isn't the NPM package being updated then? https://www.npmjs.com/package/jquery-flexdatalist
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.
@nhaberl I updated to version 2.2.4 and I still experience the same problem.
@sergiodlopes can you make a sample how to set values programmatically ?
I'm having what may be a similar issue trying to set the value without success, or at least without immediate effect. Version 2.24, but it's my first time with this plugin so keep that in mind. I'm new to Git too, so forgive me if this is a protocol violation.
This code
var journal = '<?= $journal ?>';
console.log(journal);
console.log($('#journal').val(journal));
console.log(journal == $('#journal').val());
if data-selection-required="true" gives
Drug Test. Analysis
w.fn.init [input#journal.flexdatalist.form-control.flexdatalist-set.flexdatalist-loading]
false
but if data-selection-required="false" it seems to work.
Also, it seems almost like the assignment is delayed, perhaps due to a race condition with loading/parsing a 20K JSON file? With Unicode chars.
@FiroStefani
Using data-selection-required="false"
might actually be the problem, I'm using it too.
For what it's worth, this code to monitor events:
$('#journal').on('after:flexdatalist.data', function(e, data) {
console.log('After journals loaded');
console.log(e);
console.log(data);
});
shows that the event fires on every keystroke in the #journal field. I had it expected it to fire only once, after the JSON data file for the field is loaded. I thought I might defer the assignment until then, but as it stands, doing...
$('#journal').val('foo')
...inside the event handler triggers the same event leading to stack overflow. Time for plan C ;)
I am using flexdatalist version 2.2.4 and I am not able to set a default value for url. the search in the database is done and even if the data is returned the default value is not set. how to resolve this problem with URL data? because even putting data-selection-required = "false" here does not work. I've sampled documentation with DATA and it worked.
i have the same issue. i want to select value in another flext datalist input based on the value selected in the previous one. can some one help me on this.