PDA

View Full Version : [CLOSED] Help finding html elements inside dataview - MVC Razor EXT 2.5.2



LAEUser
Jan 03, 2015, 7:24 AM
Hello

I have an MVC application - Index page will load a partial page wich loads another partial using itemsfrompartial. the page contains a dataview with a template. I would like to call a jquery plugin but it is not able the finds the elements defined inside my template.

I have tried putting the script at the end of the page and using Ext.onReady but that did not help. I am also trying to call a handler for afterrender but I can not seem to get that working. Can you help. thanks

EDIT: I was able to get working by using the Refresh handler. Can you let me know if that is a good solution.



@(
Html.X().DataView()
.ItemSelector("div.icon")
.ID("dvwgNews")
.OverItemCls("icon-hover")
.SelectedItemCls("icon-selected")
.TrackOver(true)
.PrepareData("prepareDataNews")
.Store(store =>
store.Add(Html.X().Store()
.AutoLoad(true)
.Model(X.Model()
.IDProperty("ContentID")
.Fields(
Html.X().ModelField().Name("ContentID"),
Html.X().ModelField().Name("TypeCode"),
Html.X().ModelField().Name("ProgramCode"),
Html.X().ModelField().Name("Title"),
Html.X().ModelField().Name("Content"),
Html.X().ModelField().Name("Tags"),
Html.X().ModelField().Name("Status"),
Html.X().ModelField().Name("DateExpires").Type(ModelFieldType.Date)
)
)
.Proxy(
Html.X().AjaxProxy()
.Url(Url.Action("GetPortalNews"))
.Reader(
Html.X().JsonReader().Root("data")
)
)
)
)
.Tpl(Html.X().XTemplate()
.Html(@<text>

<div class="container">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4">
<ul class="latest-news">
<tpl for=".">
<li>
<h6>{Title} <span>{DateExpires:date('F j, Y')}</span></h6>
<article>
<div class="more-content">
<p>{Content}</p>
</div>
</article>
</li>
</tpl>
</ul>
</div>
</div>
</div>

</text>)
)
.Listeners(ls => ls.AfterRender.Handler = "setMore(this);")

)

<script>

var setMore = function (el) {

debugger;

var xx = $(".more-content");
var tt = $('article');

var ttt = el.container.select('article');

var x = el;
};

Ext.onReady(function () {
debugger;

var xx = $(".more-content");
var tt = $('article');

$('article').readmore({
moreLink: '<a href="#">More examples and options</a>',
maxHeight: 390
});
}
);
</script>

}

Daniil
Jan 03, 2015, 8:06 PM
Hi @LAEUser,

Yes, I think the Refresh event is what you need in the given scenario. Please let us know if you see any issues with this approach.

LAEUser
Jan 04, 2015, 5:27 PM
you can close this request. it seems to work fine with the Refresh event