Yii Framework Forum: [Extension] Yii Booster / X-Editable - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[Extension] Yii Booster / X-Editable Rate Topic: -----

#1 User is offline   pitchinnate 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 22-May 12

Posted 29 May 2013 - 08:45 AM

I am working on a project where people can add elements to a journal entry. Certain elements allow users to later on add their results. I allow them to edit these results by using a TbEditableField widget. I add the elements via ajax to the DOM. When I do this though all new editable fields don't work since they were added after the original DOM load. They work if I refresh the page. Is there a setting with this widget so that it can work with an element added to the DOM dynamically?

Only thing I could find similar was this: jsfiddle.net/xBB5x/329/

Any help would be greatly appreciated.
0

#2 User is offline   pitchinnate 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 22-May 12

Posted 29 May 2013 - 02:30 PM

Figured out a solution myself. Here is what I did, where the widget is created:

$this->widget('bootstrap.widgets.TbEditableField', array(
	'type'      => 'text',
	'model'     => $model,
	'attribute' => 'result',
	'url'       => $this->createUrl('/controller/action'),
	'text'      => $model->result,
	'htmlOptions' => array(
		'class' => 'neweditable',
		'rel' => 'Model_result_' . $model->id,
		'data-pk' => $model->id,
	),
));


Then in the ajax call that updates the DOM I just had to add this line:

$.post(url,values,function(data) {
	if(data.complete == 'true') {
		$(journal_div).html(data.html);
		$(journal_div + ' a.neweditable').editable({'datepicker':{'language':'en'},'type':'text','url':'/controller/action','name':'result','title':'Enter Result','mode':'popup'});
	}
}, 'json');

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users