开发者

Tokenizing Autocomplete Text Entry -- how to set inital values

开发者 https://www.devze.com 2022-12-20 13:32 出处:网络
Beginner jquery question.I am using the Tokenizing Autocomplete Text Entry plugin, with the goal being to create a similar input as the SO Tags feild.

Beginner jquery question. I am using the Tokenizing Autocomplete Text Entry plugin, with the goal being to create a similar input as the SO Tags feild.

I got it pretty much working, but the issue that I am having is that when I edit my Sto开发者_StackOverflow中文版ry model (/stories/1/edit) the tags field appears blank (I guess the plugin makes a brand new text entry and hides the original text field that has my initial values)

My question is, how do I get this plugin (or sugest another plugin that can do it) to show the existing tags when editing.

Note: I am using Ruby on Rails

Thanks!


From the link you provided:

Version 1.1 Released!

  • [..]
  • Can now prepopulate the list by settings settings.prePopulate with an array of {id: n, name: blah}
  • [..]


I did this through php. I use community builder with joomla so I used the cb api to define the user and then echo the value in the value="" in the field input.

You can also do this with a simple db query similar to

$query = "SELECT username FROM something WHERE id = ". (int) $myid;
$_CB_database->setQuery( $query );
$value = htmlspecialchars( cbUnHtmlspecialchars( $_CB_database->loadResult() ) );

Then in your value="" add

<?php echo $value; ?>

For me it pre-populates both the hidden input as well as the token.

Now if I can just figure out how to use this on multiple fields without conflicting.

0

精彩评论

暂无评论...
验证码 换一张
取 消