Get name in fbautocomplete jquery plugin
Topics related to client-side programming language.
Post questions and answers about JavaScript, Ajax, or jQuery codes and scripts.
-
JanMolendijk
- Posts: 176
- Location: Holland Rotterdam
Get name in fbautocomplete jquery plugin
I`m almost their with my tag-system
But my second question for today: I can`t find-out how to detect the names from this javascript.
I can detect the id " + itemId + " this is working normal
in this part it detect the names
add2Advanced("Current selected users: " + itemId + " " + titles.join(", "));
But I can not find out what to do to detect the names like I can detect the id.
Code: Select all
<script type="text/javascript">
$(function(){
/*
*
Simple
*
*/
$('#fbautocomplete_id').fbautocomplete();
/*
*
Advanced
*
*/
$('#fbautocomplete_id_advanced').fbautocomplete({
url: 'friends.php', // which url will provide json!
maxItems: 0, // only one item can be selected
// do not use caching, always calls server even for something you have already typed.
// Probably you want to leave this on true
useCache: true,
onItemSelected : function($obj, itemId, selected) {
if (selected) {
add2Advanced("User with id = <a href='/Jan-Molendijk/Member-Profile.php?id=" + itemId + "' title='' class='postlink' target='hoofd'>" + itemId + "</a> has been added");
var titles = [];
for (var i in selected) titles[i] = selected[i].title;
add2Advanced("Current selected users: " + itemId + " " + titles.join(", "));
}
},
onItemRemoved : function($obj, itemId) {
add2Advanced('User with id = ' + itemId + ' has been removed');
},
onAlreadySelected: function($obj) {
add2Advanced('That user is already selected');
}
});
function add2Advanced(str) {
$('#advanced_actions').html($('#advanced_actions').html() + '<br />' + str);
}
});
</script>
Admin
I not know how that jquery plugin works.
In the function from onItemSelected apply the following code to see in browser console what data is in the $obj and selected parameters.
Maybe the name can be found in their values.
Code: Select all
console.log($obj);
console.log($selected);
JanMolendijk
Thanks for supporting but I still dont understand where to place the console.log ?
Something like this ?
Code: Select all
onItemSelected : function($obj, itemId, selected) {
if (selected) {
console.log($obj);
console.log($selected);
}
}
Admin
Yes, in that function.
Then, see in browser console (F12) what data is displayed.
Similar Topics
-
CKEditor imgbrowse - set plugin address
Scripts from this website
First post
Great feature! Replaced the version downloaded from CKEditor site with the zip version from this page:
No longer loads the images directory I have...
Last post
Thank you! Works great. The delete feature is very useful.
Sorry if my original request was posted in wrong thread/area.
Cheers!
-
jquery-select2 (not working)
Scripts from this website
First post
Dear admin I`m testing this script on my server
, but it does not work.
I simply did copy your code for a test on my XAMPP Version: 5.6.31...
Last post
Thank you for the support Admin,
i thought their was a problem with
the PHP-version or something else
It is working fine now (stupido me)
-
Adding jquery script to two buttons
JavaScript - jQuery - Ajax
First post
Dear admin I try to add two buttons in one off your scripts for opening via button
but i cant find out what i`m doing wrong one is opening but...
Last post
Hello,
There is no attribute id_1 . You can change the value of an atribute, but not its name.
You can use the same js script for multiple buttons;...
-
jQuery Hide and Show effect with data from php
JavaScript - jQuery - Ajax
First post
Dear Admin I would love to use this script, but their is a problem with the first record in my sql-table (DESC)
The first record (DESC) is not...
Last post
The php, javascript and html codes are wrong mixed.
It is good to avoid mixing javascript code in php strings.
- Try this:
<?php
//your...
-
Alert on jquery ajax requst when new response
JavaScript - jQuery - Ajax
First post
I have a jquery ajax function that is called every second, with setTimeout().
I want an alert to pop up whenever a new message is received.
Here's...
Last post
Try something like this, store the previous response into a variable, and alert the message if response changed:
var msg_res =''; //store the...