News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

smc_AutoSuggest

Started by Matthew K., June 11, 2014, 11:17:16 AM

Previous topic - Next topic

Matthew K.

Hello all!

So, it's been a while since I've worked with smc_AutoSuggest, and I'm working on updating "User Agreement Update", the auto-suggest feature for "bypass members" was working, but now going through and testing everything again, it isn't. The last thing I did was moved all of the mod JavaScript to an actual .js file, however, I don't think that could've caused it. I more think it's something I'm overlooking because it's been so long.

No errors in the console, or in SMF's error log.

The relevant code is below. Thanks!
<input type="text" id="bypass_members" name="bypass_members" class="input_text bloated_input" style="width: 25%;" />
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
<script type="text/javascript"><!-- // --><![CDATA[
var oBypassMembers = new smc_AutoSuggest({
sSelf: \'oBypassMembers\',
sSessionId: \'', $context['session_id'], '\',
sSessionVar: \'', $context['session_var'], '\',
sSuggestId: \'bypass_members\',
sControlId: \'bypass_members\',
sSearchType: \'member\',
bItemList: true,
sPostName: \'bypassed_members\',
sURLMask: \'action=profile;u=%item_id%\',
sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '" class="delete_item\',
sItemListContainerId: \'members_container\',
aListItems: []
});
// ]]></script>
<div id="members_container"></div>

Matthew K.

The interesting thing is, when my JavaScript file isn't included, the smc_AutoSuggest works...

Dragooon

Quote from: Labradoodle-360 on June 11, 2014, 12:05:50 PM
The interesting thing is, when my JavaScript file isn't included, the smc_AutoSuggest works...
It's probably already on the page trying to re-declare a function? Checked your console error log?

Matthew K.

There's nothing in the console log, or the SMF error log. Really strange. Thanks for your time, by the way.

live627

What is the ID of your input field? The auto suggest changes it  to "dummy_xxxxxx".

Matthew K.

Yeah, I noticed that. The code is above, and now below:
<input type="text" id="bypass_members" name="bypass_members" class="input_text bloated_input" style="width: 25%;" />

Morsyl

#6
Would the problem perhaps be that sSuggestId and sControlId are set to the same value? I'm on my phone ATM, and I don't quite remember what each of the IDs correspond to but I'm pretty sure they're meant to refer to different objects.

Edit: whoops, never mind.

Matthew K.

Any other thoughts on why this would just stop working due to some of my jQuery...?

live627

sControlId: \'bypass_members\',

should be

sControlId: \'members_container\',
<div id="members_container"></div>

Matthew K.

Making that change actually now throws a JavaScript error in my browser console coming from suggest.js:
Code (Uncaught TypeError: Cannot read property 'name' of null) Select
this.oRealTextHandle.name = this.oTextHandle.name;
What I really don't get is this did work on a previous version how it was.

Matthew K.

Any other thoughts on this, from anyone? Still not working.

live627

Quote from: live627 on June 13, 2014, 11:53:45 PM
sControlId: \'bypass_members\',

should be

sControlId: \'members_container\',
<div id="members_container"></div>
Maybe sControlId should be sSuggestId...? I always get those mixed up.

Matthew K.

I mean, it's possible. I didn't change the smc_AutoSuggest code from the previous version which didn't have any issues with suggesting. I can try it on Tuesday and we'll see...I don't think it's directly associated with the smc_AutoSuggest code, but I don't know what else would affect it that I haven't checked.

Advertisement: