inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Nov 6, 2013 9:26:32 GMT -8
Would it be possible to add a function like we have afterSearch / pageChange for after a user has selected a member from the member search? I want to grab the ID of a user selected on the 'Create Message' page after they have picked it from the user search. The afterSearch function doesn't seem to work for this purpose.
(Or is there another way to grab that information?) Cheers, Pebble.
|
|
inherit
The Dream Crusher (Ret.)
164921
0
Apr 1, 2014 11:00:25 GMT -8
Tim Camara
Teach a man to fish, etc., etc.
1,721
March 2011
tcamara
|
Post by Tim Camara on Nov 6, 2013 10:39:49 GMT -8
For generating a user select dialog and doing this, check this function. If you want to do it on the create message page, you could use set_on and check the recipients field: my cs_str = $('input[name="recipients"]').val(); // Gives you a comma-separated list of user_ids my arr = cs_str.split(","); // Splits that list into an array AfterSearch is supposed to be for the autosearch on list pages, so that wouldn't apply here. I did notice that in the documentation for set_on we neglected to mention the conversation and message options for the hook, so I've made a note to update that in the near future. You should already be able to do something like this though: (warning: untested code, there may be syntax or other errors to iron out) function get_user_ids() { return $('input[name="recipients"]').val().split(","); }
pb.plugin.key('KEY_NAME').set_on('message_new', get_user_ids());
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Nov 6, 2013 12:10:48 GMT -8
Thanks for the quick reply Tim, but I don't think that is what I'm looking for, probably because I didn't explain it well enough! What I want to do is, after each PM recipient is selected from the PBs search on the PM page - Do an action depending on the recipients id.
This is what I have so far, but it just seems like a very long way round , although it works :
$( document ).ajaxComplete(function() {
$( ".micro-profile" ).bind( "click.new_rec", function() {
setTimeout(function(){
console.log( $('input[name="recipients"]').val()); // Do stuff here
$( ".micro-profile" ).unbind( "click.new_rec" );
},1000);
});
});
EDIT : On a side note, is the extra line spacing in the code box intentional or a bug? Win 8.1 GC
|
|
inherit
The Dream Crusher (Ret.)
164921
0
Apr 1, 2014 11:00:25 GMT -8
Tim Camara
Teach a man to fish, etc., etc.
1,721
March 2011
tcamara
|
Post by Tim Camara on Nov 6, 2013 16:13:20 GMT -8
If I may ask, what is this for? There may be an alternative solution. Otherwise, I think that's about as good as it's going to get for now. If I knew more about what specifically you were trying to accomplish, I might be able to think of a different approach that would achieve the same affect.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Nov 6, 2013 22:15:29 GMT -8
The 'select' custom event generated by the selectList widget might also be what you're looking for:
$(document).on('selectlistselect', function(){console.log(arguments)})
the first arg passed to that function would of course be the event object but the second arg will be an object describing the user that was selected (id, avatar, etc.)
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Nov 7, 2013 1:05:26 GMT -8
is that function allowed to use on other then custom pages?
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Nov 7, 2013 3:46:50 GMT -8
If I may ask, what is this for? There may be an alternative solution. Otherwise, I think that's about as good as it's going to get for now. If I knew more about what specifically you were trying to accomplish, I might be able to think of a different approach that would achieve the same affect. Thanks for the info Tim. I wanted to add some predefined text to the editor, or a pb.alert, as you selected each user (if their id is in the plugin settings) . I have the plugin working apart from a bit of fine tuning. My method just seemed a bit over the top for what was simple in my head! The 'select' custom event generated by the selectList widget might also be what you're looking for: $(document).on('selectlistselect', function(){console.log(arguments)}) the first arg passed to that function would of course be the event object but the second arg will be an object describing the user that was selected (id, avatar, etc.) I never even knew this existed! I'll check it out later today and see if it fits my purpose. Cheers Chris. EDIT : $(document).on('selectlistselect', function(){console.log(arguments)}) works and is a lot less complicated than what I had. Cheers.
|
|